# spectrrt/mongodb_harnesshack architecture

> Architecture diagram of the GitHub repository spectrrt/mongodb_harnesshack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/spectrrt/mongodb_harnesshack
- Repository: https://github.com/spectrrt/mongodb_harnesshack

## Overview

Offload is a local-first agent harness for handing off recurring and long-horizon work. A user works through the workspace; assigned Sleep tasks can be queued, executed by a durable worker, checkpointed, and reviewed with verified artifacts. The REM engine adds a day/night learning cycle that replays work, evolves harness policies, and evaluates changes. Activity history and saved-session suggestions provide additional ways to identify and draft repeatable work. The graph reflects README capabilities and shown wiring; several subsystems are represented at directory level where implementation was not sampled.

Main entry points: [`server/sleep/execution.js`](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution.js) (Task execution), [`server/index.js`](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/index.js) (Local API), [`server/sleep/execution-store.js`](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-store.js) (Task queue and checkpoints), [`server/sleep/execution-routes.js`](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-routes.js) (Sleep task routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Workspace app"]
  node_workspace_ui["Workspace UI<br/>[Workspace.jsx]"]
  node_client_state["Workspace state<br/>[store.jsx]"]
  node_server["Local API<br/>[index.js]"]
end

subgraph group_execution["Durable execution"]
  node_sleep_routes["Sleep task routes"]
  node_task_store[("Task queue and checkpoints<br/>[execution-store.js]")]
  node_sleep_worker["Sleep worker"]
  node_sleep_execution["Task execution<br/>[execution.js]"]
  node_local_tools["Local tools<br/>[local-tools.js]"]
  node_model_provider["Model provider"]
  node_artifacts["Task artifacts"]
  node_harness_store[("Harness run store<br/>[store.js]")]
end

subgraph group_rem["REM learning engine"]
  node_rem_engine["REM engine<br/>[agent.js]"]
  node_rem_cycle["Day-night cycle<br/>[cycle.js]"]
  node_rem_night["Replay and evolution<br/>[night.js]"]
  node_rem_world["World model<br/>[world.js]"]
  node_rem_tasks["Task checks<br/>[tasks.js]"]
end

subgraph group_memory["Memory and activity"]
  node_context["Context compaction<br/>[compaction.js]"]
  node_activity[("Activity history<br/>[store.js]")]
  node_activity_routes["Activity API<br/>[routes.js]"]
end

subgraph group_suggestions["Suggestions"]
  node_suggestion_service["Suggestion service<br/>[service.js]"]
  node_suggestion_routes["Suggestion API<br/>[routes.js]"]
end

node_user(("User"))
node_mongo[("MongoDB")]

node_user -->|"uses"| node_workspace_ui
node_workspace_ui -->|"uses state"| node_client_state
node_client_state -->|"requests API"| node_server
node_server -->|"mounts routes"| node_sleep_routes
node_sleep_routes -->|"queues and controls"| node_task_store
node_sleep_routes -->|"serves artifacts"| node_artifacts
node_sleep_worker -->|"claims tasks"| node_task_store
node_sleep_worker -->|"runs task"| node_sleep_execution
node_sleep_execution -->|"uses tools"| node_local_tools
node_sleep_execution -->|"records progress"| node_task_store
node_sleep_execution -.->|"requests model"| node_model_provider
node_task_store -->|"persists tasks"| node_mongo
node_harness_store -->|"persists runs"| node_mongo
node_rem_engine -->|"uses world"| node_rem_world
node_rem_cycle -->|"runs harness"| node_rem_engine
node_rem_night -->|"replays and evolves"| node_rem_engine
node_rem_night -->|"tests outcomes"| node_rem_tasks
node_server -->|"mounts routes"| node_activity_routes
node_activity_routes -->|"queries history"| node_activity
node_activity_routes -->|"finds friction"| node_activity
node_server -->|"mounts routes"| node_suggestion_routes
node_suggestion_routes -->|"handles requests"| node_suggestion_service
node_suggestion_service -->|"runs workflows"| node_harness_store
node_sleep_execution -->|"compacts context"| node_context

click node_workspace_ui "https://github.com/spectrrt/mongodb_harnesshack/blob/main/src/pages/Workspace.jsx"
click node_client_state "https://github.com/spectrrt/mongodb_harnesshack/blob/main/src/store.jsx"
click node_server "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/index.js"
click node_sleep_routes "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-routes.js"
click node_task_store "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-store.js"
click node_sleep_worker "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-worker.js"
click node_sleep_execution "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution.js"
click node_local_tools "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/local-tools.js"
click node_model_provider "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-provider.js"
click node_artifacts "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-routes.js"
click node_rem_engine "https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/agent.js"
click node_rem_cycle "https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/cycle.js"
click node_rem_night "https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/night.js"
click node_rem_world "https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/world.js"
click node_rem_tasks "https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/tasks.js"
click node_context "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/context/compaction.js"
click node_activity "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/activity/store.js"
click node_activity_routes "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/activity/routes.js"
click node_suggestion_service "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/suggestions/service.js"
click node_suggestion_routes "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/suggestions/routes.js"
click node_harness_store "https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/harness/store.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workspace_ui,node_client_state,node_server,node_user toneBlue
class node_sleep_routes,node_task_store,node_sleep_worker,node_sleep_execution,node_local_tools,node_model_provider,node_artifacts,node_harness_store,node_mongo toneAmber
class node_rem_engine,node_rem_cycle,node_rem_night,node_rem_world,node_rem_tasks toneMint
class node_context,node_activity,node_activity_routes toneRose
class node_suggestion_service,node_suggestion_routes toneIndigo
```

## Components

### Workspace app

- [Workspace UI](https://github.com/spectrrt/mongodb_harnesshack/blob/main/src/pages/Workspace.jsx): `src/pages/Workspace.jsx`
- [Workspace state](https://github.com/spectrrt/mongodb_harnesshack/blob/main/src/store.jsx): `src/store.jsx`
- [Local API](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/index.js): `server/index.js`

### Durable execution

- [Sleep task routes](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-routes.js): `server/sleep/execution-routes.js`
- [Task queue and checkpoints](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-store.js): `server/sleep/execution-store.js`
- [Sleep worker](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-worker.js): `server/sleep/execution-worker.js`
- [Task execution](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution.js): `server/sleep/execution.js`
- [Local tools](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/local-tools.js): `server/local-tools.js`
- [Model provider](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-provider.js): `server/sleep/execution-provider.js`
- [Task artifacts](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/sleep/execution-routes.js): `server/sleep/execution-routes.js`
- [Harness run store](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/harness/store.js): `server/harness/store.js`

### REM learning engine

- [REM engine](https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/agent.js): `rem/agent.js`
- [Day-night cycle](https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/cycle.js): `rem/cycle.js`
- [Replay and evolution](https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/night.js): `rem/night.js`
- [World model](https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/world.js): `rem/world.js`
- [Task checks](https://github.com/spectrrt/mongodb_harnesshack/blob/main/rem/tasks.js): `rem/tasks.js`

### Memory and activity

- [Context compaction](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/context/compaction.js): `server/context/compaction.js`
- [Activity history](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/activity/store.js): `server/activity/store.js`
- [Activity API](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/activity/routes.js): `server/activity/routes.js`

### Suggestions

- [Suggestion service](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/suggestions/service.js): `server/suggestions/service.js`
- [Suggestion API](https://github.com/spectrrt/mongodb_harnesshack/blob/main/server/suggestions/routes.js): `server/suggestions/routes.js`

### Other components

- **User**
- **MongoDB**

## Connections

- User → Workspace UI: uses (evidence: `README.md`)
- Workspace UI → Workspace state: uses state (evidence: `src/main.jsx`)
- Workspace state → Local API: requests API (evidence: `src/store.jsx`)
- Local API → Sleep task routes: mounts routes (evidence: `server/index.js`)
- Sleep task routes → Task queue and checkpoints: queues and controls (evidence: `server/sleep/execution-routes.js`)
- Sleep task routes → Task artifacts: serves artifacts (evidence: `server/sleep/execution-routes.js`)
- Sleep worker → Task queue and checkpoints: claims tasks (evidence: `server/sleep/execution-worker.js`)
- Sleep worker → Task execution: runs task (evidence: `server/sleep/execution-worker.js`)
- Task execution → Local tools: uses tools (evidence: `server/sleep/execution.js`)
- Task execution → Task queue and checkpoints: records progress (evidence: `server/sleep/execution.js`)
- Task execution → Model provider: requests model
- Task queue and checkpoints → MongoDB: persists tasks (evidence: `server/sleep/execution-store.js`)
- Harness run store → MongoDB: persists runs (evidence: `server/harness/store.js`)
- REM engine → World model: uses world (evidence: `rem/index.js`)
- Day-night cycle → REM engine: runs harness (evidence: `rem/index.js`)
- Replay and evolution → REM engine: replays and evolves (evidence: `README.md`)
- Replay and evolution → Task checks: tests outcomes (evidence: `rem/tasks.js`)
- Local API → Activity API: mounts routes (evidence: `server/index.js`)
- Activity API → Activity history: queries history (evidence: `server/activity/routes.js`)
- Activity API → Activity history: finds friction (evidence: `server/activity/routes.js`)
- Local API → Suggestion API: mounts routes (evidence: `server/index.js`)
- Suggestion API → Suggestion service: handles requests (evidence: `server/suggestions/routes.js`)
- Suggestion service → Harness run store: runs workflows (evidence: `server/suggestions/service.js`)
- Task execution → Context compaction: compacts context (evidence: `server/sleep/execution.js`)
