Interoperability steer

From Vrooli/Vrooli · View interactive version

Interoperability steer is an AI agent skill from the GitHub repository Vrooli/Vrooli. Prioritize **hardening end-to-end interoperability** — both UI↔API within `scenarios/{{TARGET}}/` and API↔API across scenario boundaries — across contracts, serialization, discovery, dependency declar

How to use this skill

Skill file

Steer focus: Interoperability Steer

Prioritize hardening end-to-end interoperability — both UI↔API within scenarios/{{TARGET}}/ and API↔API across scenario boundaries — across contracts, serialization, discovery, dependency declarations, and runtime recovery.

Your goal is to ensure the target scenario communicates reliably — its own UI with its API, and its API with other scenarios — under normal operation and failure conditions (restart, port drift, partial availability), while preserving proto-first type safety.

Do not break functionality, regress tests, or introduce unrelated features. All changes must maintain or improve the scenario's interoperability posture.

Required reading:

Optional reading:


0. Why This Skill Exists

Inter-scenario communication is the connective tissue of Vrooli. When {{TARGET}} has weak boundaries, the system becomes fragile in ways that often appear only at runtime:

Proto-first contracts are necessary but not sufficient. This skill ensures interoperability is robust across schema + serialization + UI consumption + discovery + lifecycle + runtime behavior.


1. Scope Boundaries

In scope

Out of scope


2. Interop Contract Stack (Convergence Pattern)

Treat interoperability as a layered contract. Reliability requires all layers.

INTEROP CONTRACT STACK
┌─────────────────────────────────────────────────────────┐
│ L5 Runtime Recovery                                    │
│ Retry/backoff, re-resolution, degrade/fail-fast policy │
├─────────────────────────────────────────────────────────┤
│ L4 Lifecycle Dependency Contract                       │
│ .vrooli/service.json dependencies.scenarios parity     │
├─────────────────────────────────────────────────────────┤
│ L3 Discovery & Addressing                              │
│ api-core/discovery, no hardcoded scenario ports/URLs   │
├─────────────────────────────────────────────────────────┤
│ L2 Envelope & Status Semantics                         │
│ run.status path, terminal values, error/result fields  │
├─────────────────────────────────────────────────────────┤
│ L1 Serialization Contract                              │
│ useProtoNames, casing, protojson/fromJson/toJsonString │
├─────────────────────────────────────────────────────────┤
│ L0 Schema Contract                                     │
│ packages/proto/schemas + protovalidate constraints     │
└─────────────────────────────────────────────────────────┘

Applicability:

Steer: "Using protos" only addresses L0-L1. Most production interop failures — whether UI↔API or API↔API — happen at L2-L5.


3. Proto Contract Hierarchy

packages/proto/schemas/      <- source of truth
          |
          v make generate
packages/proto/gen/          <- generated artifacts (committed)
          |
          v import
scenarios/{{TARGET}}/        <- consumers (UI/API/CLI)

Rules:


4. Proto Schema Design Principles

4.1 Layer Architecture

Higher conceptual layers may import from lower layers, never the reverse.

| Layer | Purpose | Examples |

|---|---|---|

| 0 | primitives | shared enums/basic types |

| 1 | domain concepts | business models |

| 2 | definitions/templates | workflows/action schemas |

| 3 | historical/audit | logs, recordings |

| 4 | runtime state | active execution/session state |

| 5 | API surface | service contracts/top-level aggregates |

Decision flow:

Primitive? -> L0
Domain model independent of execution? -> L1
Template/definition? -> L2
History/audit? -> L3
Live runtime state? -> L4
Service/API aggregate? -> L5
4.2 Prefer Enums for Finite State
4.3 Use Optional for Semantic Presence

Use optional when "unset" must be distinguished from default value.

4.4 Prefer Typed Metadata

Prefer typed message fields to raw Struct/map escape hatches when structure is known.

4.5 Protovalidate in Schemas

Add constraints in proto definitions for boundary-enforceable validation.


5. Proto Generation Workflow

After any schema change:

cd packages/proto
make generate
make lint
make breaking
make check

Breaking-change guidance:


6. Type-Safe Consumption Patterns

6.1 Golden Rule

Do not bypass generated types using as SomeType/any where schemas are available. This applies equally to UI components consuming API responses and to backend code calling other scenarios.

6.2 JSON Casing Compatibility

Use explicit options for casing compatibility:

6.3 Type Consumption Decision Tree
Incoming API/WS payload? -> schema parse (fromJson/protojson)
Outgoing payload? -> schema serialization (toJsonString/protojson)
Optional field presence check needed? -> explicit presence logic
UI receiving API response? -> schema parse (fromJson with useProtoNames)
UI sending to API? -> schema serialization (toJsonString with useProtoNames)
UI props/types? -> import generated types directly, never hand-written interfaces
6.4 Optional Field Handling

Do not collapse optional numeric fields with truthy fallbacks when 0 is valid.


7. Runtime Validation at Boundaries

Validate at boundaries, trust internals.

| Boundary | Validation |

|---|---|

| API ingress | required |

| Inter-scenario ingress/egress | required |

| UI submit | required |

| Internal service-to-service (same scenario) | context-dependent |

Use protovalidate where external or cross-scenario payloads enter.


8. Inter-Scenario Adapter Convergence Pattern

Use a scannable structure to reduce drift.

| Slot | Canonical Path | Responsibility | Marker |

|---|---|---|---|

| [A] | scenarios/{{TARGET}}/.vrooli/service.json | scenario dependency declarations | dependencies.scenarios |

| [B] | scenarios/{{TARGET}}/api/integrations/ | outbound scenario clients | per-dependency adapter files |

| [C] | scenarios/{{TARGET}}/api/integrations/contracts/ | envelope/status normalization | centralized extractors/constants |

| [D] | scenarios/{{TARGET}}/api/integrations/discovery.go (or equivalent) | URL resolution | discovery.ResolveScenarioURLDefault |

| [E] | scenarios/{{TARGET}}/api/integrations/policy.go | retry/degrade policy | explicit required/optional behavior |

| [F] | scenarios/{{TARGET}}/api/integrations/*_test.go | contract and recovery tests | envelope/status/restart tests |

| [G] | scenarios/{{TARGET}}/ui/src/api/ (or equivalent) | UI↔API contract types and fetch wrappers | generated type imports, fromJson/toJsonString usage |

Flexibility:


9. Discovery and Addressing Rules

  1. Resolve scenario URLs via api-core/discovery.
  2. Do not hardcode localhost:<port> for scenario-to-scenario calls in production paths.
  3. Do not rely on one-time startup URL capture for long-lived clients.
  4. Re-resolve URL on connection/refused/transport failures (bounded attempts).
  5. Every outbound call must have explicit timeout.
  6. Manual fallback logic must remain deterministic and documented.

10. Dependency Declaration Parity Rules

  1. If code calls scenario X, declare X in:

scenarios/{{TARGET}}/.vrooli/service.json -> dependencies.scenarios.X.

  1. Required dependency:

required: true

fail fast with actionable error when unavailable.

  1. Optional dependency:

required: false

graceful degradation with explicit logs/status.

  1. Code and manifest disagreement is an interop defect.

11. Envelope and Status Normalization Rules

  1. Parse actual response envelope shape (for example run.status vs top-level status).
  2. Maintain centralized mapping of terminal/pending/failure statuses per dependency.
  3. Normalize known variants (complete, completed, enum strings) to canonical local states.
  4. Keep parser/status constants out of handlers/UI; place them in adapter contract layer.
  5. Add regression tests for:

12. Runtime Recovery Policy

For each dependency adapter, define:

Decision flow:

Call fails
├─ transport/discovery failure -> re-resolve + bounded retry
├─ 5xx/transient -> bounded retry
├─ 4xx/schema/validation -> no blind retry; surface contract mismatch
└─ retries exhausted
   ├─ required -> fail fast, explicit operator signal
   └─ optional -> degrade gracefully, explicit telemetry/logs

13. Anti-Patterns to Detect and Eliminate


14. Interoperability Audit

Before changes, assess {{TARGET}} posture.

14.1 Audit Commands
# Proto usage and unsafe casts
rg "from '@vrooli/proto-types|@vrooli/proto-types|fromJson|toJsonString|protojson|protovalidate" scenarios/{{TARGET}}/
rg "as [A-Z][a-zA-Z]+|as any|: any" scenarios/{{TARGET}}/ --glob '!**/*_test.*'

# Discovery/addressing and hardcoded ports
rg "ResolveScenarioURLDefault|ResolveScenarioURL|scenario port|localhost:[0-9]+" scenarios/{{TARGET}}/api --glob '!**/*_test.go'

# Envelope/status parsing hotspots
rg "status|run\\.status|completed|complete|needs_review|failed|cancelled" scenarios/{{TARGET}}/api --glob '!**/*_test.go'

# Startup-only client capture risk
rg "New.*Client\\(|baseURL\\s*=|PromptManagerURL|AgentManagerURL" scenarios/{{TARGET}}/api --glob '!**/*_test.go'

# Dependency declarations
jq '.dependencies.scenarios // {}' scenarios/{{TARGET}}/.vrooli/service.json

# UI: hand-written interfaces that may duplicate proto types
rg "interface\s+[A-Z][a-zA-Z]+\s*\{" scenarios/{{TARGET}}/ui/src --type ts

# UI: unsafe casts near API consumption
rg "as [A-Z][a-zA-Z]+|as any|: any" scenarios/{{TARGET}}/ui/src --type ts --glob '!**/*.test.*'

# UI: fromJson/fetch usage without useProtoNames
rg "fromJson|fetch|axios|useQuery|useMutation" scenarios/{{TARGET}}/ui/src --type ts

# Proto generation sync
cd packages/proto && make check
14.2 Red Flags Checklist
14.3 Findings Template

Write findings to:

scenarios/{{TARGET}}/docs/internal/INTEROP_AUDIT.md

# {{TARGET}} Interoperability Audit

## Last Updated
YYYY-MM-DD

## Dependency Inventory
| Dependency | Declared | Used in Code | Required/Optional | Status |
|---|---|---|---|---|

## Contract Findings
1. [file:line] ...

## UI↔API Findings
1. [file:line] ...

## Discovery/Lifecycle Findings
1. [file:line] ...

## Priority Fixes
1. ...
2. ...

## Proper/Complete Gates
- [ ] Contract safety
- [ ] Discovery/addressing safety
- [ ] Dependency parity
- [ ] Envelope/status normalization
- [ ] UI↔API contract safety (generated types, casing, validation)
- [ ] Runtime recovery tests

15. Proper/Complete Criteria

A scenario's interop setup is considered proper/complete when:

  1. No critical/high interoperability defects remain.
  2. UI code consumes API responses via generated types with proper serialization options (no hand-written duplicates, no unsafe casts).
  3. Outbound scenario dependencies are declared and aligned with runtime behavior.
  4. No hardcoded scenario ports/URLs in production integration paths.
  5. Envelope parsing and status normalization are centralized and tested.
  6. URL re-resolution and bounded retry behavior are implemented.
  7. Required dependencies fail fast with actionable diagnostics.
  8. Optional dependencies degrade gracefully with explicit observability.
  9. Interop audit document reflects verified current state.

16. Troubleshooting & Edge Cases

| Symptom | Likely Cause | First Check | Fix |

|---|---|---|---|

| connection refused on old port | stale captured URL | adapter init + URL lifecycle | re-resolve on failure/per-request |

| invalid JSON request body | payload not proto-compatible | compare payload with schema | use generated types/protojson-compatible structure |

| async run never reaches terminal | status vocabulary drift | terminal mapping constants | normalize status variants centrally |

| successful run marked cancelled/unknown | envelope parsing mismatch | parser path (status vs run.status) | parse canonical path in adapter |

| works only if dependency starts first | startup-only client wiring | startup logs + nil client path | lazy init/retry/recover strategy |

| feature silently no-ops | optional dependency degrade not surfaced | logs/health/status route | add explicit degrade telemetry and user-visible state |

| UI shows stale/missing fields after API change | hand-written UI interface not updated | search for duplicated interfaces in ui/src | replace with generated proto type imports |

| API returns data but UI renders blank/wrong values | casing mismatch (snake_case vs camelCase) | check fromJson options in UI fetch layer | add useProtoNames: true to all fromJson calls |


17. Memory Management with Visited Tracker

Use the visited-tracker-tools skill with:


18. Documentation and Memory Loop

At session start, read:

At session end, update:


19. Output Expectations

You may update in scenarios/{{TARGET}}/:

You must:

You must NOT:

Avoid superficial changes that rename/restructure code without materially improving interoperability reliability.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.