# t-auto/dsh-ops architecture

> Architecture diagram of the GitHub repository t-auto/dsh-ops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/t-auto/dsh-ops
- Repository: https://github.com/t-auto/dsh-ops

## Overview

dsh-ops is a DSH performance-tools plugin: users receive repository/file tools, a bash-first shell with PowerShell fallback, managed background jobs, and an opt-in native PTC batch/result capability. The main runtime path is DSH component registration, followed by policy-governed tool execution; native Rust workers provide file and PTC operations. The map includes documented capabilities whose detailed implementation was not sampled. Evidence is limited to the excerpts, SOURCE INDEX references, and README statements provided.

Main entry points: [`lib/index.js`](https://github.com/t-auto/dsh-ops/blob/main/lib/index.js) (Component registration), [`native/src/lib.rs`](https://github.com/t-auto/dsh-ops/blob/main/native/src/lib.rs) (Native dispatch), [`lib/ptc/worker.js`](https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/worker.js) (PTC worker bridge), [`lib/session-shells.js`](https://github.com/t-auto/dsh-ops/blob/main/lib/session-shells.js) (Bash session tool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Plugin and policy"]
  node_host_entry["Component registration<br/>[index.js]"]
  node_config["Configuration<br/>[config.js]"]
  node_policy["Tool policy<br/>[policy.js]"]
  node_permissions["Permission checks<br/>[permissions.js]"]
  node_workspace["Workspace preparation"]
  node_binary["Runtime discovery<br/>[binary.js]"]
end

subgraph group_shell["Shell execution"]
  node_shell_resolve["Shell discovery<br/>[shells.js]"]
  node_shell_session["Bash session tool<br/>[session-shells.js]"]
  node_bash_ipc["Bash IPC bridge<br/>[bash-ipc.js]"]
end

subgraph group_files["File tools"]
  node_file_contract["File tool contracts<br/>[contract.js]"]
  node_file_bridge["File worker bridge<br/>[worker.js]"]
end

subgraph group_ptc["PTC and jobs"]
  node_ptc_contract["PTC tool contract<br/>[contract.js]"]
  node_ptc_worker["PTC worker bridge<br/>[worker.js]"]
  node_ptc_runtime["PTC runtime discovery<br/>[runtime.js]"]
  node_background["Background job tools<br/>[index.js]"]
  node_jobs["Job management<br/>[jobs.js]"]
end

subgraph group_native["Native runtime"]
  node_ipc_security["IPC security<br/>[security.h]"]
  node_file_native["Native file operations<br/>[file.rs]"]
  node_file_paths["Path confinement<br/>[file_path.rs]"]
  node_native_contract["Worker request contract<br/>[contract.rs]"]
  node_native_dispatch["Native dispatch<br/>[lib.rs]"]
  node_native_store[("Audit and result store<br/>[store.rs]")]
  node_native_results["Paged results<br/>[results.rs]"]
  node_batch["Batch execution<br/>[batch.rs]"]
end

node_user(("DSH user / agent"))
node_host_services["DSH policy and process services"]
node_fastctx["FastCtx runtime"]
node_shell_payloads["Bundled bash / PowerShell"]
node_worker_payload["Native worker executable"]

node_user -->|"selects component"| node_host_entry
node_host_entry -->|"resolves config"| node_config
node_host_entry -->|"registers tools"| node_policy
node_host_entry -->|"resolves runtime"| node_binary
node_host_entry -->|"resolves shells"| node_shell_resolve
node_host_entry -->|"publishes tools"| node_file_contract
node_host_entry -->|"mounts bash"| node_shell_session
node_host_entry -->|"resolves worker"| node_ptc_runtime
node_binary -->|"locates executable"| node_fastctx
node_host_entry -->|"starts runtime"| node_fastctx
node_shell_resolve -.->|"finds executables"| node_shell_payloads
node_host_entry -.->|"provides shell tools"| node_shell_payloads
node_shell_session -->|"prepares workspace"| node_workspace
node_shell_session -->|"confines and spawns"| node_host_services
node_shell_session -->|"executes via bridge"| node_bash_ipc
node_bash_ipc -->|"uses security helpers"| node_ipc_security
node_user -.->|"requests file operation"| node_file_contract
node_file_contract -->|"defines operations"| node_file_bridge
node_file_bridge -->|"checks write access"| node_permissions
node_file_bridge -->|"resolves policy and spawns"| node_host_services
node_file_bridge -.->|"dispatches request"| node_native_dispatch
node_native_dispatch -->|"validates request"| node_native_contract
node_native_dispatch -->|"dispatches file tools"| node_file_native
node_file_native -->|"uses path handling"| node_file_paths
node_user -.->|"starts or manages jobs"| node_background
node_host_entry -->|"publishes job tools"| node_background
node_background -.->|"manages jobs"| node_jobs
node_user -.->|"requests batch or result"| node_ptc_contract
node_host_entry -.->|"loads opt-in component"| node_ptc_contract
node_ptc_contract -->|"defines tool operations"| node_ptc_worker
node_ptc_worker -->|"checks authorization"| node_permissions
node_ptc_worker -->|"prepares workspace"| node_workspace
node_ptc_worker -->|"confines and spawns"| node_host_services
node_ptc_worker -->|"resolves worker"| node_ptc_runtime
node_ptc_runtime -->|"selects executable"| node_worker_payload
node_ptc_worker -.->|"dispatches request"| node_native_dispatch
node_native_dispatch -->|"runs batch"| node_batch
node_native_dispatch -->|"runs result queries"| node_native_results
node_native_dispatch -->|"opens durable store"| node_native_store
node_batch -->|"stores bounded results"| node_native_results

click node_host_entry "https://github.com/t-auto/dsh-ops/blob/main/lib/index.js"
click node_config "https://github.com/t-auto/dsh-ops/blob/main/lib/config.js"
click node_policy "https://github.com/t-auto/dsh-ops/blob/main/lib/policy.js"
click node_permissions "https://github.com/t-auto/dsh-ops/blob/main/lib/permissions.js"
click node_workspace "https://github.com/t-auto/dsh-ops/blob/main/lib/workspace-preparation.js"
click node_binary "https://github.com/t-auto/dsh-ops/blob/main/lib/binary.js"
click node_shell_resolve "https://github.com/t-auto/dsh-ops/blob/main/lib/shells.js"
click node_shell_session "https://github.com/t-auto/dsh-ops/blob/main/lib/session-shells.js"
click node_bash_ipc "https://github.com/t-auto/dsh-ops/blob/main/lib/bash-ipc.js"
click node_ipc_security "https://github.com/t-auto/dsh-ops/blob/main/native/bash-ipc/security.h"
click node_file_contract "https://github.com/t-auto/dsh-ops/blob/main/lib/file/contract.js"
click node_file_bridge "https://github.com/t-auto/dsh-ops/blob/main/lib/file/worker.js"
click node_file_native "https://github.com/t-auto/dsh-ops/blob/main/native/src/file.rs"
click node_file_paths "https://github.com/t-auto/dsh-ops/blob/main/native/src/file_path.rs"
click node_native_contract "https://github.com/t-auto/dsh-ops/blob/main/native/src/contract.rs"
click node_native_dispatch "https://github.com/t-auto/dsh-ops/blob/main/native/src/lib.rs"
click node_native_store "https://github.com/t-auto/dsh-ops/blob/main/native/src/store.rs"
click node_native_results "https://github.com/t-auto/dsh-ops/blob/main/native/src/results.rs"
click node_ptc_contract "https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/contract.js"
click node_ptc_worker "https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/worker.js"
click node_ptc_runtime "https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/runtime.js"
click node_batch "https://github.com/t-auto/dsh-ops/blob/main/native/src/batch.rs"
click node_background "https://github.com/t-auto/dsh-ops/blob/main/lib/components/background/index.js"
click node_jobs "https://github.com/t-auto/dsh-ops/blob/main/lib/jobs.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_host_entry,node_config,node_policy,node_permissions,node_workspace,node_binary,node_user toneBlue
class node_shell_resolve,node_shell_session,node_bash_ipc toneAmber
class node_file_contract,node_file_bridge toneMint
class node_ptc_contract,node_ptc_worker,node_ptc_runtime,node_background,node_jobs,node_worker_payload toneRose
class node_ipc_security,node_file_native,node_file_paths,node_native_contract,node_native_dispatch,node_native_store,node_native_results,node_batch,node_host_services,node_fastctx,node_shell_payloads toneIndigo
```

## Components

### Plugin and policy

- [Component registration](https://github.com/t-auto/dsh-ops/blob/main/lib/index.js): `lib/index.js`
- [Configuration](https://github.com/t-auto/dsh-ops/blob/main/lib/config.js): `lib/config.js`
- [Tool policy](https://github.com/t-auto/dsh-ops/blob/main/lib/policy.js): `lib/policy.js`
- [Permission checks](https://github.com/t-auto/dsh-ops/blob/main/lib/permissions.js): `lib/permissions.js`
- [Workspace preparation](https://github.com/t-auto/dsh-ops/blob/main/lib/workspace-preparation.js): `lib/workspace-preparation.js`
- [Runtime discovery](https://github.com/t-auto/dsh-ops/blob/main/lib/binary.js): `lib/binary.js`

### Shell execution

- [Shell discovery](https://github.com/t-auto/dsh-ops/blob/main/lib/shells.js): `lib/shells.js`
- [Bash session tool](https://github.com/t-auto/dsh-ops/blob/main/lib/session-shells.js): `lib/session-shells.js`
- [Bash IPC bridge](https://github.com/t-auto/dsh-ops/blob/main/lib/bash-ipc.js): `lib/bash-ipc.js`

### File tools

- [File tool contracts](https://github.com/t-auto/dsh-ops/blob/main/lib/file/contract.js): `lib/file/contract.js`
- [File worker bridge](https://github.com/t-auto/dsh-ops/blob/main/lib/file/worker.js): `lib/file/worker.js`

### PTC and jobs

- [PTC tool contract](https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/contract.js): `lib/ptc/contract.js`
- [PTC worker bridge](https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/worker.js): `lib/ptc/worker.js`
- [PTC runtime discovery](https://github.com/t-auto/dsh-ops/blob/main/lib/ptc/runtime.js): `lib/ptc/runtime.js`
- [Background job tools](https://github.com/t-auto/dsh-ops/blob/main/lib/components/background/index.js): `lib/components/background/index.js`
- [Job management](https://github.com/t-auto/dsh-ops/blob/main/lib/jobs.js): `lib/jobs.js`

### Native runtime

- [IPC security](https://github.com/t-auto/dsh-ops/blob/main/native/bash-ipc/security.h): `native/bash-ipc/security.h`
- [Native file operations](https://github.com/t-auto/dsh-ops/blob/main/native/src/file.rs): `native/src/file.rs`
- [Path confinement](https://github.com/t-auto/dsh-ops/blob/main/native/src/file_path.rs): `native/src/file_path.rs`
- [Worker request contract](https://github.com/t-auto/dsh-ops/blob/main/native/src/contract.rs): `native/src/contract.rs`
- [Native dispatch](https://github.com/t-auto/dsh-ops/blob/main/native/src/lib.rs): `native/src/lib.rs`
- [Audit and result store](https://github.com/t-auto/dsh-ops/blob/main/native/src/store.rs): `native/src/store.rs`
- [Paged results](https://github.com/t-auto/dsh-ops/blob/main/native/src/results.rs): `native/src/results.rs`
- [Batch execution](https://github.com/t-auto/dsh-ops/blob/main/native/src/batch.rs): `native/src/batch.rs`

### Other components

- **DSH user / agent**
- **DSH policy and process services**
- **FastCtx runtime**
- **Bundled bash / PowerShell**
- **Native worker executable**

## Connections

- DSH user / agent → Component registration: selects component (evidence: `README.md`)
- Component registration → Configuration: resolves config (evidence: `lib/index.js`)
- Component registration → Tool policy: registers tools (evidence: `lib/index.js`)
- Component registration → Runtime discovery: resolves runtime (evidence: `lib/index.js`)
- Component registration → Shell discovery: resolves shells (evidence: `lib/index.js`)
- Component registration → File tool contracts: publishes tools (evidence: `lib/index.js`)
- Component registration → Bash session tool: mounts bash (evidence: `lib/index.js`)
- Component registration → PTC runtime discovery: resolves worker (evidence: `lib/index.js`)
- Runtime discovery → FastCtx runtime: locates executable (evidence: `lib/binary.js`)
- Component registration → FastCtx runtime: starts runtime (evidence: `lib/index.js`)
- Shell discovery → Bundled bash / PowerShell: finds executables (evidence: `README.md`)
- Component registration → Bundled bash / PowerShell: provides shell tools (evidence: `README.md`)
- Bash session tool → Workspace preparation: prepares workspace (evidence: `lib/session-shells.js`)
- Bash session tool → DSH policy and process services: confines and spawns (evidence: `lib/session-shells.js`)
- Bash session tool → Bash IPC bridge: executes via bridge (evidence: `lib/session-shells.js`)
- Bash IPC bridge → IPC security: uses security helpers
- DSH user / agent → File tool contracts: requests file operation (evidence: `README.md`)
- File tool contracts → File worker bridge: defines operations (evidence: `lib/file/runtime.js`)
- File worker bridge → Permission checks: checks write access (evidence: `lib/file/worker.js`)
- File worker bridge → DSH policy and process services: resolves policy and spawns (evidence: `lib/file/worker.js`)
- File worker bridge → Native dispatch: dispatches request
- Native dispatch → Worker request contract: validates request (evidence: `native/src/lib.rs`)
- Native dispatch → Native file operations: dispatches file tools (evidence: `native/src/lib.rs`)
- Native file operations → Path confinement: uses path handling (evidence: `native/src/file.rs`)
- DSH user / agent → Background job tools: starts or manages jobs (evidence: `README.md`)
- Component registration → Background job tools: publishes job tools (evidence: `lib/index.js`)
- Background job tools → Job management: manages jobs
- DSH user / agent → PTC tool contract: requests batch or result (evidence: `README.md`)
- Component registration → PTC tool contract: loads opt-in component (evidence: `README.md`)
- PTC tool contract → PTC worker bridge: defines tool operations (evidence: `lib/ptc/index.js`)
- PTC worker bridge → Permission checks: checks authorization (evidence: `lib/ptc/worker.js`)
- PTC worker bridge → Workspace preparation: prepares workspace (evidence: `lib/ptc/worker.js`)
- PTC worker bridge → DSH policy and process services: confines and spawns (evidence: `lib/ptc/worker.js`)
- PTC worker bridge → PTC runtime discovery: resolves worker (evidence: `lib/ptc/worker.js`)
- PTC runtime discovery → Native worker executable: selects executable (evidence: `lib/ptc/runtime.js`)
- PTC worker bridge → Native dispatch: dispatches request
- Native dispatch → Batch execution: runs batch (evidence: `native/src/lib.rs`)
- Native dispatch → Paged results: runs result queries (evidence: `native/src/lib.rs`)
- Native dispatch → Audit and result store: opens durable store (evidence: `native/src/lib.rs`)
- Batch execution → Paged results: stores bounded results (evidence: `native/src/batch.rs`)
