Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .agents/skills/minos-quality-gate/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
name: minos-quality-gate
description: Run and remediate Minos CI-equivalent quality gates for a completed change. Use after any code, test, schema, codegen, dependency, configuration, documentation, comment, rename, or deletion change and before every commit, push, PR update, or handoff; use again when addressing a CI failure.
---

# Minos local quality gate

Use this as the required final phase of a change. CI confirms a locally green
change; it is not a discovery loop. Do not hand off, commit, or push while a
selected gate has failed, been skipped by a missing prerequisite, or has not
been run.

`docs/ci-gates.md` is the local-gate contract. Read it before selecting
commands. Inspect `.github/workflows/ci.yml` for CI-only setup and exact steps
such as SQLx metadata, the mobile code-generator, or the macOS desktop check.
If the two disagree, resolve the current contract at its owner and update the
documentation in the same change; do not invent a third command list here.

## 1. Determine the final change surface

Inspect the complete working tree, including staged and untracked files:

```bash
git status --short
git diff --name-only
git diff --cached --name-only
git ls-files --others --exclude-standard
```

Classify every in-scope changed path, including deletions, generated files,
comments, and renames. Do not validate only the last file edited. Preserve
unrelated user changes; a whole-tree gate can expose their failure, but do not
silently fix or discard them. Report such a failure as not green rather than
claiming the task passed.

Changes to a comment, a name, or a deleted file retain the gate of their source
language/surface. For example, a Rust doc-comment change can require rustfmt,
clippy, or FRB regeneration; a Desktop rename still requires the file-size
gate.

## 2. Run every applicable gate

Use the composite commands below rather than substituting a convenient subset.
They preserve the CI phase order and, for Rust, `clippy --keep-going`.

| Changed surface | Required local evidence |
| --- | --- |
| Rust workspace: root Cargo files, `crates/**`, `xtask/**`, `schemas/**`, migrations, `.sqlx/**`, `justfile` | `cargo xtask check-rust`. This includes fmt, naming/docs lints, backend platform-contract drift, schema parity, clippy with warnings denied, workspace tests, and daemon `test-support` tests. For `minos-backend`, migrations, SQL queries, or `.sqlx`, also reproduce the workflow's `cargo sqlx prepare --check --workspace -- -p minos-backend --all-targets` step with its SQLite `DATABASE_URL`; install the workflow-pinned `sqlx-cli` first if necessary. Run `just check-backend-pg` for migration/storage-parity changes when its local Postgres prerequisite is available. |
| Desktop TypeScript, Desktop config/dependencies, or `apps/desktop/src-tauri/**` | `cd apps/desktop && pnpm check:all`; on macOS also run `cargo check -p minos-desktop`. `check:all` is mandatory because it includes tests, Biome, file-size, and px-text gates. If the dependency manifest or lockfile changed, first use `pnpm install --frozen-lockfile`. |
| Web TypeScript/config/dependencies under `apps/web/**` | `cd apps/web && pnpm check`. If the dependency manifest or lockfile changed, first use `pnpm install --frozen-lockfile`. |
| Mobile Dart, mobile dependencies, FRB config, `minos-mobile`, or `minos-ffi-frb` | Run `cargo xtask check-all` after confirming that `fvm` and `flutter_rust_bridge_codegen` are available; do not count its toolchain-dependent skip as a pass. Also reproduce the mobile CI sequence from `.github/workflows/ci.yml`: `flutter pub get`; `dart run build_runner build --delete-conflicting-outputs`; `dart format --set-exit-if-changed lib test`; `dart analyze --fatal-warnings`; and `flutter test --exclude-tags ffi`. Use the workflow's temporary plugin-disable step for analysis, not a permanent `analysis_options.yaml` edit. Regenerate FRB with `cargo xtask gen-frb` (or the workflow command) and verify a second generation produces no change. |
| Backend platform contract/OpenAPI/WebSocket schema | `cargo xtask check-rust`; its static phase runs `gen-backend-platform-contract --check`. Do not manually edit generated artifacts to mask drift. |
| Project documentation or agent instructions only | `cargo xtask lint-docs` when documentation paths are affected. For a skill change, run that skill's declared validator as well. |

For a cross-surface change, run the union of rows. `cargo xtask check-all` is
the preferred aggregate on a prepared macOS/mobile machine, but it does not
replace `pnpm check:all` for Desktop or `pnpm check` for Web.

Before running FRB drift against Git, distinguish intended generated edits from
new generator output: generate once, include the intended artifacts in the
change, then generate again. The second run must leave the generated roots
unchanged. On a clean final commit, also run the workflow's `git diff
--exit-code` check for `apps/mobile/lib/src/rust` and
`crates/minos-ffi-frb/src/frb_generated.rs`, plus check for untracked output.

## 3. Fix and re-run to green

Treat every failure as a defect in the final change until evidence proves it is
an unrelated pre-existing worktree issue. Trace the owning code or contract,
make the smallest correct repair, regenerate committed artifacts when required,
and re-run the failed gate. Then re-run all selected composite gates so an
earlier failure does not hide a later one. Do not waive a lint, loosen an
allowlist, suppress a test, or leave generated drift merely to make a gate
green.

If a required platform/toolchain is unavailable, install/use the repository's
pinned prerequisite when that is in scope. Otherwise report the gate as
unavailable and request the needed environment; do not call the work complete
or imply that CI will cover it.

## 4. Hand off with evidence

State the complete change surfaces and each selected command with its exit
result. Mark non-applicable gates as `not applicable` with the path-based
reason. List any unavailable gate or unrelated worktree failure explicitly.
Only describe the change as complete when every applicable gate exited zero.

Example:

```text
Quality gates
- Rust workspace + backend contract: cargo xtask check-rust — passed
- Desktop: apps/desktop pnpm check:all — passed
- Mobile/Web: not applicable (no paths changed)
```
4 changes: 4 additions & 0 deletions .agents/skills/minos-quality-gate/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "Minos Quality Gate"
short_description: "Run CI-equivalent checks before handoff"
default_prompt: "Use $minos-quality-gate to verify this Minos change before handoff."
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ Documentation is a maintained product surface, not a record of agent activity. K

## Verification and completion

- Do not declare work complete without evidence. Compare behavior with the base branch when relevant, run the applicable quality gates, inspect meaningful logs or errors, and report the results.
- Use the project [minos-quality-gate](.agents/skills/minos-quality-gate/SKILL.md) skill as the mandatory final phase of every code, test, schema, codegen, dependency, configuration, documentation, comment, rename, or deletion change. Before any commit, push, PR update, or handoff, classify the complete changed surface, run every selected CI-equivalent local gate, repair failures, and re-run to green. CI confirms this evidence; it must not be the first place an agent discovers formatting, lint, codegen, contract, file-size, or test failures.
- Do not declare work complete without evidence. Compare behavior with the base branch when relevant, run the applicable quality gates, inspect meaningful logs or errors, and report the exact commands and results. Explicitly mark only path-based non-applicable gates; a missing toolchain/platform or an unrun required gate is a blocker, not a passing result.
- Review completed work adversarially: trace the broader call chain, state, lifecycle, and failure modes for unexpected behavior. Find the root cause rather than only the reported symptom, then proactively inspect and correct analogous paths to preserve whole-codebase correctness.
- Unit tests cover isolated business rules, state changes, parsing, validation, serialization, and error handling. Mock external systems; do not label UI, network, database, filesystem, device, or end-to-end flows as unit tests.
- Keep integration and UI coverage separate, and run the relevant test command before handoff.
Expand Down
85 changes: 53 additions & 32 deletions apps/mobile/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This document describes the layered architecture of the Minos mobile app,
following the [Flutter Architecture Best Practices](.agents/skills/flutter-apply-architecture-best-practices/SKILL.md).

Product spine: **conversation-first collaboration IM**. Shell tabs are
Messages / Hosts / Account. Agent session transcript, projects, sessions
inbox, and Agents Hub were removed from the Mobile product surface.

## Directory Structure

```
Expand All @@ -11,59 +15,59 @@ lib/
├── architecture.dart # Architecture overview (dartdoc)
│
├── domain/ # Domain Layer (pure Dart)
│ ├── models.dart # Barrel export for all domain models
│ ├── models.dart # Barrel export for domain models
│ ├── minos_core_protocol.dart # Abstract service contract (DI boundary)
│ ├── active_session.dart # Agent session state machine
│ ├── auth_state.dart # Auth lifecycle states
│ ├── agent_profile.dart # Agent configuration model
│ ├── agent_profile.dart # Local bot cache / draft model
│ ├── social_message.dart # Chat message model
│ ├── group_member.dart # Group membership model
│ └── minos_error_display.dart # Error presentation helpers
│
├── infrastructure/ # Data Layer — Services
│ ├── minos_core.dart # Rust FFI bridge (implements MinosCoreProtocol)
│ ├── secure_pairing_store.dart# Keychain persistence
│ ├── social_cache_store.dart # SQLite message cache
│ ├── social_cache_store.dart # SQLite message cache + outbox SQL
│ ├── im_outbox_store.dart # Outbox policy helpers
│ ├── agent_profile_store.dart # JSON file persistence
│ ├── app_paths.dart # Platform path resolution
│ └── workspace_mru_store.dart # MRU workspace persistence
│ └── app_paths.dart # Platform path resolution
│
├── data/ # Data Layer — Repositories (barrel exports)
│ ├── repositories/
│ │ └── repositories.dart # Re-exports repository providers
│ └── services/
│ └── services.dart # Re-exports infrastructure services
├── data/ # Data Layer — Repositories / services
│ ├── repositories/ # Concrete repository providers + adapters
│ └── services/ # Concrete service/store providers
│
├── application/ # Application Layer — ViewModels (Riverpod)
│ ├── minos_providers.dart # Core data providers (repository role)
│ ├── minos_providers.dart # Connection / hosts / presence
│ ├── auth_provider.dart # Auth state controller
│ ├── active_session_provider.dart # Agent session lifecycle
│ ├── thread_events_provider.dart # Live event stream
│ ├── thread_list_provider.dart # Session list data
│ ├── project_providers.dart # Project CRUD + selection
│ ├── social_providers.dart # Social chat state management
│ ├── agent_profiles_provider.dart # Agent profile CRUD
│ ├── group_agent_provider.dart # Group agent bindings
│ ├── group_agent_dispatcher.dart # Agent mention dispatch
│ ├── social/ # Conversation IM feature modules
│ │ ├── social_conversation_state.dart # freezed timeline state
│ │ ├── social_conversation_notifier.dart
│ │ ├── social_inbox_notifier.dart
│ │ ├── social_chat_view_model.dart # feature ViewModel
│ │ ├── social_chat_actions.dart # intentful actions
│ │ ├── social_ui_state.dart
│ │ ├── social_friends_providers.dart
│ │ └── social_realtime_sync.dart
│ ├── social_providers.dart # Compatibility barrel for social/*
│ ├── im_outbox_worker.dart # Local IM outbox drain
│ ├── agent_profiles_provider.dart # Local bot cache for compose
│ ├── agent_conversation_actions.dart # Create agent conversation
│ ├── group_agent_provider.dart # Participants / mention roster
│ ├── social_actions.dart # DM / group create actions
│ ├── preferred_agent_provider.dart # Preferred agent selection
│ ├── ui_state_providers.dart # Shell tab + login form state
│ ├── log_records_provider.dart # Debug log mirror
│ ├── request_trace_records_provider.dart # Request trace mirror
│ └── root_route_decision.dart # Navigation decision logic
│
├── data/
│ ├── repositories/ # Concrete repository providers + adapters
│ └── services/ # Concrete service/store providers
│
├── ui/ # UI Layer — Feature-organized implementation
├── ui/ # UI Layer — Feature-organized implementation
│ ├── core/
│ │ └── widgets/widgets.dart # Shared widget exports
│ └── features/
│ ├── auth/ # Auth screens/widgets + barrel
│ ├── chat/ # Agent session screens/widgets + barrel
│ ├── projects/ # Project screens/widgets + barrel
│ ├── agents/ # Agent management screens/widgets + barrel
│ ├── social/ # Social screens/widgets + barrel
│ ├── pairing/ # Pairing screens/widgets + barrel
│ ├── messages/ # Conversation inbox (primary tab)
│ ├── social/ # Conversation chat / members + chrome
│ ├── hosts/ # Linked hosts list
│ ├── account/ # Profile / logout
│ ├── debug/ # Debug screens/widgets + barrel
│ └── shell/ # Root app shell, router, navigation
│
Expand All @@ -82,12 +86,15 @@ lib/
- `data/services/` contains provider-backed service/store access used by repositories.
- `infrastructure/` contains raw concrete implementations such as `MinosCore` and persistence stores.
- `MinosCore` implements `MinosCoreProtocol`; FRB remains isolated to infrastructure/generated code.
- `RealtimeEventsRepository` exposes Account `uiEvents` only (snapshot/presence/notices). Thread/project/agent-session compose APIs are not part of the Mobile contract.

### Application Layer (`lib/application/`)
- Riverpod providers acting as ViewModels.
- Manages UI state, handles user interactions, orchestrates data flow.
- Riverpod providers acting as ViewModels (codegen `@riverpod` preferred).
- Per-feature aggregation: UI watches feature ViewModels (e.g. `SocialChatViewModel`) and calls Action facades instead of many fine-grained providers.
- Complex timeline state uses freezed immutable models (`SocialConversationState`).
- Depends on `domain/` models and `data/repositories/`, never on `ui/` or `infrastructure/` directly.
- Root dependency injection happens in `main()` by overriding `minosCoreServiceProvider`.
- Collaboration send path: `SocialChatActions` → `SocialConversation` → outbox → `sendChatMessage`.

### UI Layer (`lib/ui/`)
- `ui/` contains the actual widget implementations and feature barrels.
Expand All @@ -107,6 +114,20 @@ Repositories coordinate service/store access while preserving domain-facing APIs
The Infrastructure layer implements domain protocols and low-level persistence.
No circular dependencies exist between layers.

## Routes (IM-first)

| Route | Page | Purpose |
|-------|------|---------|
| `/splash` | splash | bootstrap |
| `/login` | `LoginPage` | auth |
| `/` | `AppShellPage` | Messages / Hosts / Account |
| `/social` | redirect → `/` | legacy inbox deep link |
| `/social/chat/:conversationId` | `SocialChatPage` | conversation timeline |
| `/social/chat/:conversationId/members` | `GroupMembersPage` | members |
| `/log-viewer` | `LogViewerPage` | debug |

Removed from product: `/thread/*`, `/sessions`, `/agent-start`, `/agent-profile/*`, `/project/*`.

## Adding a New Feature

1. Define domain models in `lib/domain/` (if new entities are needed).
Expand Down
Loading
Loading