Skip to content

[codex] Build Strand cockpit TUI#5

Draft
TSchonleber wants to merge 8 commits into
mainfrom
codex/strand-cockpit-tui
Draft

[codex] Build Strand cockpit TUI#5
TSchonleber wants to merge 8 commits into
mainfrom
codex/strand-cockpit-tui

Conversation

@TSchonleber
Copy link
Copy Markdown
Owner

@TSchonleber TSchonleber commented Apr 24, 2026

Summary

  • Add the strand cockpit operator entrypoint and a width-safe, gamified Ink dashboard with mission/pulse/shield/reach panels.
  • Wire the cockpit to the existing local operator snapshot data: review queue, action stats, guardrails, X health, and follower deltas.
  • Add Phase 3/4 metrics plumbing, docs/runbook updates, CLI/status/review surfacing, and focused coverage for the cockpit and actor behavior.
  • S5: Skill lifecycle + brainctl integration + Ink renderer bridge (Devin-4)

Why

The existing TUI wrapped badly in normal terminal widths and hid the available controls. This makes the cockpit usable as a pinned terminal: clearer controls, responsive rendering, a ? help menu, and tests that enforce 80-column safety.

S5 Changes (Devin-4)

Skill storage (src/db/schema.sql):

  • skill_records table: tracks per-skill usage_count, success_count, token_cost_samples_json (for p50/p95), last_used_at, trust_score, triggers, supersedes, and status (active | retired | draft | queued_draft | queued_retire).
  • skill_decisions table: audit trail of accept/reject decisions with 30-day rejection suppression.

Skill lifecycle (src/agent/skills/lifecycle.ts):

  • SkillRecordStore: upsert, usage recording, status transitions, per-status listing.
  • runNightlyScorer(): queues retire proposals when hit-rate < 0.15, success-rate < 0.5 (n >= 10), or superseded. Respects 30-day rejection suppression.
  • acceptProposal() / rejectProposal(): transition skill status and record decisions.

Brainctl integration:

  • toBrainctlDecisionEvent(): maps SkillDecision to brainctl-compatible event shape.
  • SkillDecisionStore.record() auto-computes suppressed_until on rejection (30 days).

Ink renderer bridge (src/cockpit/ink/bridge.ts):

  • createInkBridge(): subscribes to core EventBus, optional type filtering, destroy() cleanup.
  • createSkillEventBridge(): filtered bridge for skill.proposal + skill.decision events.
  • Classic gamified TUI preserved; this adds the chat-first renderer path alongside it.

Validation

  • pnpm typecheck — clean
  • pnpm exec vitest run tests/agent/skill-lifecycle.test.ts tests/cockpit/ink-bridge.test.ts — 20 tests pass
  • pnpm exec biome check — clean on all touched files

Review & Testing Checklist for Human

  • Verify skill_records / skill_decisions schema matches §6 expectations
  • Confirm nightly scorer thresholds (0.15 hit-rate, 0.5 success-rate with n>=10) match spec intent
  • Check brainctl adapter shape (BrainctlDecisionEvent) — clean adapter path, slots into brainctl skill category when it's added

Notes

  • CockpitEvent schema NOT altered — skill.proposal and skill.decision types were already in S0 scaffold
  • S4 frontmatter shape consumed, not rewritten — triggers_json mirrors what S4 skill files declare
  • Ink bridge depends only on cockpit/core events, maintaining the two-invariant contract

Link to Devin session: https://app.devin.ai/sessions/181c7d5b9b714a65af8850685f1556f5
Requested by: @TSchonleber

TSchonleber and others added 8 commits April 24, 2026 05:26
Design spec for the cockpit rework. Pivots strand from twitter-engine-
monitor to chat-first operator cockpit. Covers:

- provider/subagent/skill architectural split (hermes-agent pattern)
- auth model: BYOK + PKCE device-code + oauth_external credential reuse
  with honest billing warnings (anthropic extra_usage routing, etc.)
- pinned cockpit event schema for parallel ink + web renderers
- subagent spawn with cli-process backend (claude, codex) + budget
  inheritance + depth/concurrency caps
- skill lifecycle (markdown + sqlite) with queued reflexion-driven
  retirement, integrated as a brainctl memory category
- workstream decomposition for codex + 4 devin + 1 claude-code sprint

Hard constraints call out the non-negotiables: policy gate preservation,
pinned renderer protocol, local-only oauth_external, no implicit env-var
activation, queued skill retirement.

References hermes-agent (NousResearch) as the primary reference impl.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…iders, flow-gate timeline

- elevate "lean by default" as a cross-cutting principle: JIT skill
  retrieval, --bare default for subagents, summarizing context engine
  default, cheapest-capable reflexion judge, lean default budgets
- add hard constraint #8 pinning lean session budget defaults
- prune provider list to anthropic / openai / xai / gemini / openai-compat
  (the long tail is reachable via openai-compat + baseURL, no new adapters)
- remove nous-portal from the v1 registry
- replace day-by-day sprint timeline with flow-gated checkpoints — agents
  move faster than calendar time

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- SQLite skill_records + skill_decisions tables (schema.sql)
- SkillRecordStore: upsert, usage metrics, status transitions
- SkillDecisionStore: accept/reject with 30-day rejection suppression
- Nightly scorer: queued_retire on low hit-rate (<0.15), low success-rate
  (<0.5 with n>=10), or superseded by higher-scoring skill
- brainctl adapter: toBrainctlDecisionEvent for decision event logging
- Ink bridge: createInkBridge + createSkillEventBridge for chat-first
  renderer consuming CockpitEvent streams (preserves classic TUI)
- 20 tests: lifecycle store, scorer, accept/reject, suppression, bridge

Co-Authored-By: Terrence Schonleber <TVschonleber@gmail.com>
…depth enforcement

- cli-process backend with oneshot mode, CockpitEvent normalization
- Parsers: claude-code-stream, codex-exec, raw-text fallback
- --bare flag contract: never with oauth_external, default with api_key (HC#7)
- maxDepth 3, maxConcurrentChildren 3, heartbeat 30s, stale 10min
- Seed skills: claude-code.md, codex.md, pr-review.md (frontmatter per §6)
- 45 tests covering parsers, --bare logic, budget, depth, concurrency

Co-Authored-By: Terrence Schonleber <TVschonleber@gmail.com>
Co-Authored-By: Terrence Schonleber <TVschonleber@gmail.com>
…d device-code scaffolding

- Provider registry for anthropic, openai, xai, gemini, openai-compat
- CockpitAuthStore (~/.strand/auth.json) with single-writer lock
- External credential discovery for Claude Code and gemini-cli
- OpenAI oauth_device_code flow with mockable HTTP client
- Enforce hard constraints #3 (oauth_external local-only), #4 (billing warning), #5 (no implicit activation)
- 39 tests across 4 test files

Co-Authored-By: Terrence Schonleber <TVschonleber@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant