Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
08304c9
feat(calm-server): add initial files for calm-server
markscott-ms Feb 22, 2026
bb14d87
feat(calm-server): copy server functionality into calm-server
markscott-ms Feb 22, 2026
63903ba
feat(calm-server): bundle schema into calm-server
markscott-ms Feb 22, 2026
5fdab6c
feat(calm-server): add tests
markscott-ms Feb 23, 2026
39a9951
feat(calm-server): listen on 127.0.0.1 by default, with --host option
markscott-ms Feb 23, 2026
4b1ca5b
feat(calm-server): rate limiting options rather than hardcoded
markscott-ms Feb 24, 2026
e9df2d8
feat(calm-server): remove cli config - expect options on the command …
markscott-ms Feb 25, 2026
bb70238
feat(calm-server): update README and AGENTS.md
markscott-ms Feb 25, 2026
802adef
feat(ci): add calm-server build workflow
markscott-ms Feb 25, 2026
6531027
chore(calm-server): update PR template to include missing modules
markscott-ms Feb 25, 2026
8b7a18f
chore(calm-server): fix lint issues
markscott-ms Feb 25, 2026
5d0cc41
feat(calm-server): address review comments
markscott-ms Feb 25, 2026
49a698f
chore(ci): add calm-server as a valid scope for commitlint
markscott-ms Feb 25, 2026
e72edcb
fix(calm-server): suppress unused var in tests
markscott-ms Feb 25, 2026
0bfe35b
feat(calm-server): improve test coverage, remove CLI references
markscott-ms Feb 26, 2026
aca06df
Merge branch 'main' into issues/2051-calm-server
markscott-ms Feb 26, 2026
f016f1b
feat(calm-server): add CODEOWNERS, avoid deep fragile linking
markscott-ms Feb 26, 2026
48bd001
feat(calm-server): update README
markscott-ms Feb 26, 2026
40287aa
Merge branch 'main' into issues/2051-calm-server
markscott-ms Feb 26, 2026
1ae9ffa
feat(calm-server): only import exported functions and types from shared
markscott-ms Feb 28, 2026
e82ecb1
Merge branch 'issues/2051-calm-server' of https://github.com/markscot…
markscott-ms Feb 28, 2026
bd0bb1b
Merge branch 'main' into issues/2051-calm-server
markscott-ms Feb 28, 2026
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

/calm-hub/ @jpgough-ms @rocketstack-matt @grahampacker-ms @Thels @markscott-ms

/calm-server/ @rocketstack-matt @markscott-ms

/cli/ @aidanm3341 @lbulanti-ms @willosborne @grahampacker-ms @jpgough-ms @rocketstack-matt @Thels @LeighFinegold @markscott-ms

/shared/ @aidanm3341 @lbulanti-ms @willosborne @grahampacker-ms @jpgough-ms @rocketstack-matt @Thels @LeighFinegold @markscott-ms
Expand Down
7 changes: 5 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
## Affected Components
<!-- Check all that apply -->
- [ ] CLI (`cli/`)
- [ ] Shared (`shared/`)
- [ ] CALM Widgets (`calm-widgets/`)
- [ ] Schema (`calm/`)
- [ ] CALM AI (`calm-ai/`)
- [ ] CALM Hub (`calm-hub/`)
- [ ] CALM Hub UI (`calm-hub-ui/`)
- [ ] CALM Server (`calm-server/`)
- [ ] CALM Widgets (`calm-widgets/`)
- [ ] Documentation (`docs/`)
- [ ] Shared (`shared/`)
- [ ] VS Code Extension (`calm-plugins/vscode/`)
- [ ] Dependencies
- [ ] CI/CD
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/build-calm-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build CALM Server

permissions:
contents: read

on:
pull_request:
branches:
- 'main'
- 'release*'
push:
branches:
- 'main'
- 'release*'

jobs:
calm-server:
name: Build, Test, and Lint CALM Server Module
runs-on: ubuntu-latest

steps:
- name: Checkout PR Branch
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6

- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
with:
node-version: v22

- name: Install workspace
run: npm ci

- name: Lint CALM Server Module
run: npm run lint --workspace=calm-server

- name: Build workspace
run: npm run build:calm-server

- name: Run tests with coverage for CALM Server
run: npm run test:calm-server
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Ready to get started? Check out the [CALM tutorials](https://calm.finos.org/tuto
| [CALM AI](./calm-ai) | [@rocketstack-matt](https://github.com/rocketstack-matt) | No build, prompt tools only, managed separately to CLI for easier maintenance and broader reuse. |
| [CALM Hub](./calm-hub) | [@jpgough-ms](https://github.com/jpgough-ms), [@grahampacker-ms](https://github.com/grahampacker-ms) | [![Build Calm Hub](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub.yml) |
| [CALM Hub UI](./calm-hub-ui) | [@aidanm3341](https://github.com/aidanm3341), [@aamanrebello](https://github.com/aamanrebello), [@yoofitt96](https://github.com/YoofiTT96) | [![Build CALM Hub UI](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub-ui.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-hub-ui.yml) |
| [CALM-Server](./calm-server) | [@rocketstack-matt](https://github.com/rocketstack-matt), [@markscott-ms](https://github.com/markscott-ms) | [![Build CALM Server](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-server.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-calm-server.yml) |
| [Docs](./docs) | [@rocketstack-matt](https://github.com/rocketstack-matt) | [![Sync Docs to S3](https://github.com/finos/architecture-as-code/actions/workflows/s3-docs-sync.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/s3-docs-sync.yml) [![Build Docs](https://github.com/finos/architecture-as-code/actions/workflows/build-docs.yml/badge.svg)](https://github.com/finos/architecture-as-code/actions/workflows/build-docs.yml) |
| [CALM VSCode Plugin](./calm-plugins/vscode) | [@LeighFinegold](https://github.com/LeighFinegold), [@rocketstack-matt](https://github.com/rocketstack-matt), [@markscott-ms](https://github.com/markscott-ms) | ![Build VS Code Extension](https://github.com/finos/architecture-as-code/workflows/Build%20VS%20Code%20Extension/badge.svg) |

Expand Down
168 changes: 168 additions & 0 deletions calm-server/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# @finos/calm-server

The `calm-server` executable provides a standalone HTTP server implementation of CALM validation functionality.

## Architecture

The calm-server provides:

- **Bundled CALM Schemas** - All CALM schemas (release and draft) are bundled during build
- **Health Check Endpoint** (`/health`) - Status endpoint for monitoring
- **Validation Endpoint** (`/calm/validate`) - POST endpoint for validating CALM architectures
- **Rate Limiting** - Protects against abuse with 100 requests per 15 minutes per IP

## Project Structure

```
calm-server/
├── src/
│ ├── index.ts # Entry point, CLI argument parsing
│ ├── server/
│ │ ├── cli-server.ts # Express server startup
│ │ └── routes/
│ │ ├── routes.ts # Router setup
│ │ ├── health-route.ts # Health check endpoint
│ │ └── validation-route.ts # Architecture validation endpoint
│ └── *.spec.ts # Unit tests
├── dist/
│ ├── index.js # Compiled executable
│ └── calm/ # Bundled CALM schemas
│ ├── release/ # Released schema versions
│ └── draft/ # Draft schema versions
├── package.json
├── tsconfig.json
├── tsconfig.build.json
├── tsup.config.ts # Build configuration
├── vitest.config.ts # Test configuration
└── eslint.config.mjs # Linting configuration
```

## Building & Running

### Build the package
```bash
npm run build:calm-server
```

This builds the TypeScript code and copies all CALM schemas from `calm/release` and `calm/draft` into `dist/calm/`.

### Run the server locally
```bash
# Using bundled schemas (default)
./calm-server/dist/index.js --port 3000 --verbose

# Or with custom schemas
./calm-server/dist/index.js -s ../calm/release --port 3000 --verbose

# Or using npm
npm run build:calm-server
node calm-server/dist/index.js --port 3000
```

### Global installation (for development)
```bash
npm run link:calm-server

# Use bundled schemas (default)
calm-server --port 3000

# Or provide custom schemas
calm-server -s /path/to/schemas --port 3000
```

## Command-Line Options

```
Usage: calm-server [options]

CALM Server - A server implementation for the Common Architecture Language Model

Options:
-V, --version output the version number
--port <port> Port to run the server on (default: "3000")
--host <host> Host to bind the server to (default: "127.0.0.1")
-s, --schema-directory <path> Path to the directory containing the meta schemas to use.
(default: bundled schemas in dist/calm)
-v, --verbose Enable verbose logging (default: false)
-c, --calm-hub-url <url> URL to CALMHub instance
--rate-limit-window <ms> Rate limit window in milliseconds (default: 900000 = 15 minutes)
--rate-limit-max <requests> Max requests per IP within the rate limit window (default: 100)
-h, --help display help for command
```

### Security Notes

- **Default Host**: The server binds to `127.0.0.1` (localhost) by default
- **No Authentication**: The server has **NO authentication or authorization controls**
- **Network Exposure Warning**: If you bind to a non-localhost host (e.g., `0.0.0.0`, `::`, public IP), a warning will be logged. Only do this in trusted network environments

## Testing

### Run tests
```bash
npm run test:calm-server
```

### Test the health endpoint
```bash
# Start the server (uses bundled schemas)
node calm-server/dist/index.js &
SERVER_PID=$!

# Test health
curl http://localhost:3000/health

# Clean up
kill $SERVER_PID
```

### Test the validation endpoint
```bash
# With a CALM architecture JSON
curl -X POST http://localhost:3000/calm/validate \
-H "Content-Type: application/json" \
-d '{"architecture": "{\"$schema\": \"https://...\"...}"}'
```

## Dependencies

- `@finos/calm-shared` - Shared utilities, validation logic, schema handling
- `express` - HTTP server framework
- `express-rate-limit` - Rate limiting middleware
- `commander` - CLI argument parsing

## Development Notes

### Copying from CLI

The calm-server implementation mirrors the server functionality from the CLI package (`cli/src/server/`):

- `src/server/cli-server.ts` - Express server setup
- `src/server/routes/routes.ts` - Route configuration
- `src/server/routes/health-route.ts` - Health check
- `src/server/routes/validation-route.ts` - Architecture validation

Both implementations share the same core logic for validation and schema handling through the `@finos/calm-shared` package.

### Build Configuration

The tsup configuration:
- Bundles shared packages (`@finos/calm-shared`, `@finos/calm-models`, `@finos/calm-widgets`)
- Adds Node.js shebang via banner for executable
- Outputs CommonJS format with tree-shaking enabled
- Marks external `node_modules` as external (not bundled)

## Linking for Development

After building, you can link the executable globally:

```bash
npm run link:calm-server
calm-server --help
```

This allows testing the executable without needing to build or reference the dist directory.

## License

Apache-2.0
142 changes: 142 additions & 0 deletions calm-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# @finos/calm-server

A standalone HTTP server for the Common Architecture Language Model (CALM) validation functionality.

The `calm-server` executable provides HTTP endpoints for CALM architecture validation.

## Features

- **Bundled CALM Schemas** - All CALM schemas (release and draft) are bundled with the executable
- **Health Check Endpoint** (`GET /health`) - Status endpoint for monitoring
- **Validation Endpoint** (`POST /calm/validate`) - Validate CALM architectures against schemas

## Usage

### Starting the Server

```bash
# Basic usage (uses bundled schemas by default)
calm-server

# With custom port
calm-server --port 8080

# With verbose logging
calm-server --port 3000 --verbose

# Or provide a custom schema directory
calm-server -s /path/to/calm/schemas --port 3000
```

### Command-Line Options

```
Usage: calm-server [options]

Options:
-V, --version output the version number
--port <port> Port to run the server on (default: "3000")
--host <host> Host to bind the server to (default: "127.0.0.1")
-s, --schema-directory <path> Path to the directory containing the meta schemas
(default: bundled schemas in dist/calm)
-v, --verbose Enable verbose logging (default: false)
-c, --calm-hub-url <url> URL to CALMHub instance
--rate-limit-window <ms> Rate limit window in milliseconds (default: 900000 = 15 minutes)
--rate-limit-max <requests> Max requests per IP within the rate limit window (default: 100)
-h, --help display help for command
```

### Security Considerations

- **Default Host is Localhost**: By default, the server binds to `127.0.0.1` for security
- **No Built-in Authentication**: This server has no authentication or authorization controls
- **Network Exposure**: When binding to non-localhost addresses, a security warning is logged. Only expose to the network in trusted environments

## API Endpoints

### Health Check

Check if the server is running:

```bash
curl http://localhost:3000/health
```

Response:
```json
{
"status": "OK"
}
```

### Validate Architecture

Validate a CALM architecture document:

```bash
curl -X POST http://localhost:3000/calm/validate \
-H "Content-Type: application/json" \
-d '{
"architecture": "{\"$schema\":\"https://calm.finos.org/release/1.2/meta/calm.json\",\"nodes\":[]}"
}'
```

Response (success):
```json
{
"jsonSchemaValidationOutputs":[],
"spectralSchemaValidationOutputs":[],
"hasErrors":false,
"hasWarnings":false
}
```

Response (validation errors):
```json
{
"jsonSchemaValidationOutputs":[],
"spectralSchemaValidationOutputs":[...],
"hasErrors":true,
"hasWarnings":false
}
```

## Development

### Building

```bash
# From repository root
npm run build:calm-server

# Or from calm-server directory
cd calm-server
npm run build
```

### Testing

```bash
# From repository root
npm run test:calm-server

# Or from calm-server directory
cd calm-server
npm test

# With coverage
npm test -- --coverage
```

### Linting

```bash
# From calm-server directory
npm run lint
npm run lint-fix
```

## License

Apache-2.0

Loading
Loading