Skip to main content
Glama

Alpha Research Orchestrator

An offline-first, evidence-gated research engine for bounded and reconstructable Alpha experiments. SQLite is the source of truth: candidate identities, state transitions, gate decisions, simulation attempts, retries, lineage, policy snapshots, and stop reasons are persisted.

This repository is an independent clean-room implementation. CNHKMCP and BrainMachine were read-only architectural evidence; this project does not import, vendor, modify, or depend on either system. The frozen contracts and safety boundaries are user-authored design decisions, and all implementation code here is new.

Current package architecture

A researcher starts the CLI or the narrow offline MCP interface. That interface borrows the deterministic orchestration services, which connect to a SQLite ledger and an explicitly selected adapter, and produces a reconstructable report that stops at human review. The LLM can propose; deterministic code owns identity, validation, limits, routing, lineage, and platform-state interpretation. The package contains no submission capability.

See the detailed architecture, sanitized replay case study, test evidence, design tradeoffs, known limits, and 60-second technical explanation.

Related MCP server: machine-mcp

Implemented milestones

Implemented:

  • installable Python 3.11+ package and English Typer CLI;

  • Pydantic v2 boundary contracts;

  • SQLAlchemy 2.x SQLite schema and Alembic migration;

  • conservative canonical identity and pre-simulation deduplication;

  • transactional state transitions, decisions, events, and parent-child lineage;

  • versioned routing, limit, and error-taxonomy policies;

  • deterministic structural validation, routing, backpressure, and stopping;

  • bounded retries with stable idempotency keys;

  • FakeBrainAdapter and sanitized ReplayBrainAdapter;

  • deterministic Markdown run reports and structured secret-redacting logs;

  • private Markdown inventory containing hashes and traceable section locators, not raw text;

  • explicit paraphrased method-card block extraction, human approval, and immutable approved versions;

  • approved-card-only tag filtering with deterministic BM25-style lexical ranking;

  • versioned generator and repair prompts persisted with their content hashes;

  • proposal-only CandidateGenerator with explicit uncertainty and single-parent RepairPlanner contracts;

  • OpenAI-compatible client configuration, strict Pydantic output validation, and an LLM request ledger that stores hashes, frozen snapshot/MethodCard version manifests, and usage metadata rather than raw inputs or outputs;

  • explicitly configured live BRAIN access using a protected external session-cookie file;

  • content-addressed field, operator, and setting snapshots frozen to one research cell;

  • idempotent simulation creation, one-step polling, normalized metrics and error classes, and bounded Retry-After handling;

  • live platform-check recording that preserves PASS, FAIL, WARNING, PENDING, and ERROR and promotes only a confirmed all-pass response to human review;

  • a local stdio MCP 2.x server exposing five narrow ledger and replay tools with typed structured output and explicit read/write annotations;

  • a portfolio evidence set covering the current architecture, one executed sanitized replay, verification evidence, tradeoffs, known limits, and a concise technical explanation.

Explicitly deferred: a Web dashboard and automatic submission. A local routing result is never described as platform approval. LLM and BRAIN calls occur only when the user explicitly supplies their separate configurations; replay remains fully offline.

Install and verify

python -m pip install -e '.[dev]'
ruff format --check .
ruff check .
mypy src
pytest

Automated tests use only in-memory fakes or local replay JSON. They never contact WorldQuant.

Offline example

alpha-lab init --db alpha_lab.db
RUN_ID=$(alpha-lab run create \
  --dataset demo-dataset --region USA --universe TOP1000 --delay 1 \
  --adapter replay --db alpha_lab.db)
alpha-lab run execute "$RUN_ID" --adapter replay \
  --fixture tests/fixtures/basic_replay.json --db alpha_lab.db
alpha-lab run status "$RUN_ID" --db alpha_lab.db
alpha-lab report "$RUN_ID" --db alpha_lab.db

run stop records an exact human stop reason. run resume reconstructs work from SQLite and does not repeat completed simulations. There is intentionally no submit command.

Private corpus and method cards

alpha-lab corpus inventory /path/to/private/markdown \
  --source-type training --db alpha_lab.db
alpha-lab corpus extract SRC-... --db alpha_lab.db
alpha-lab cards list --status draft --db alpha_lab.db
alpha-lab cards approve MC-... --reviewer "Reviewer Name" --db alpha_lab.db

Extraction recognizes only explicit method-card YAML fences whose content is already paraphrased. Drafts cannot influence retrieval until a human approval record exists. Forum experience can guide a proposal after approval, but deterministic gates never convert it into a platform rule.

Optional proposal LLM

The library exposes CandidateGenerator and RepairPlanner; both validate complete output before inserting any candidate. Configure the client only through the ALPHA_LAB_LLM_* environment variables shown in .env.example. API keys are represented as secret values in memory and are not persisted. Automated tests intercept the HTTP boundary and never contact an external endpoint.

Authorized live boundary

Live mode is disabled unless ALPHA_LAB_BRAIN_SESSION_FILE points to an external JSON cookie mapping or browser-exported cookie list. On Unix, the file must have no group or other-user access (for example, chmod 600 /outside/repository/brain-session.json). The adapter probes /authentication before any protected request and classifies an inquiry challenge as HUMAN_VERIFICATION_REQUIRED; browser login alone is not treated as proof that the HTTP client is authenticated.

alpha-lab run create \
  --dataset DATASET_ID --region USA --universe TOP1000 --delay 1 \
  --adapter live --db alpha_lab.db
alpha-lab run execute RUN_ID --adapter live --db alpha_lab.db
alpha-lab platform-check CANDIDATE_ID --db alpha_lab.db

Each execution performs at most one poll of a pending simulation and persists the external ID, so run resume continues without creating the simulation again. platform-check requires a completed live simulation and never submits it. Before execution, proposals are inserted through the library's CandidateGenerator; the live adapter deliberately does not generate expressions. Endpoint paths can be overridden with the ALPHA_LAB_BRAIN_*_PATH variables in .env.example.

Milestone 3 verification used intercepted HTTP responses only: no real WorldQuant login, simulation, or platform check was performed. The default endpoint contract therefore remains to be confirmed against an authorized account before first live use.

MCP interface

alpha-lab-mcp runs the local server over stdio using the official MCP Python SDK 2.x. Configure the ledger and optional replay fixture in the host process; tool callers cannot replace either path:

export ALPHA_LAB_MCP_DATABASE_PATH=/absolute/path/alpha_lab.db
export ALPHA_LAB_MCP_REPLAY_FIXTURE=/absolute/path/sanitized-replay.json
alpha-lab-mcp

The exposed tools are alpha_run_status, alpha_run_report, alpha_method_cards_list, alpha_replay_execute, and alpha_run_stop. The first three are read-only. The two write tools can only advance/resume an existing replay run or record the fixed MCP_REQUESTED_STOP reason. There are no MCP tools for live BRAIN access, LLM invocation, corpus reads, card approval, arbitrary filesystem paths, or Alpha submission.

Trust boundary

  • Policy thresholds allocate research effort; they are not evidence of tradability.

  • READY_FOR_PLATFORM_CHECK means only that offline routing selected a candidate.

  • PASS, FAIL, WARNING, PENDING, and ERROR remain distinct platform-check values.

  • Credentials belong only in environment variables or user-owned session files. They are redacted from persisted errors and logs and are never included in fixtures.

  • The package has no submit method or CLI command; every surviving Alpha stops at human review.

Available Tools

5 tools
alpha_method_cards_listB
Read-onlyIdempotent

List stored method-card identities and human-review states.

ParametersJSON Schema
NameRequiredDescriptionDefault
statusNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
cardsYes

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, and the description aligns with that by saying 'List'. It adds that the result contains identities and human-review states, but does not disclose pagination, ordering, or filtering behavior beyond the schema's enum. No contradiction with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence of eight words with no filler. It is front-loaded with the action and resource, making it immediately scannable.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple: one optional parameter, read-only annotations, and an output schema exists. The description covers what is returned, but the complete lack of parameter guidance leaves a meaningful gap for an agent trying to use the status filter correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for the missing parameter meaning. The only parameter, 'status', is not mentioned anywhere in the description. An agent must infer from the enum and default null that it is an optional filter, but the description adds no value beyond the schema itself.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('List') and a clear resource ('method-card identities and human-review states'). It is immediately distinct from the sibling tools, which are all run/replay operations, so an agent can tell this is the listing tool without confusion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit when-to-use guidance or mention of alternatives. The purpose itself implies usage for retrieving method-card listings, but the description does not explain when to choose this over siblings or how the optional status parameter affects the listing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

alpha_replay_executeC

Execute or resume one replay-mode run using the operator-configured fixture.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
run_idYes
statusYes
stop_reasonYes
adapter_modeNo
distinct_candidatesYes
simulation_attemptsYes
automatic_submission_availableNo

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations are all false, so the description carries the full burden of behavioral disclosure. It states 'Execute or resume' indicating mutation, but does not describe side effects, whether the call blocks, or what the output contains. The phrase 'operator-configured fixture' hints at a prerequisite but lacks detail on what that entails.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no filler. It front-loads the action ('Execute or resume') and includes the key context of the fixture. It is concise and appropriately sized, though it could have added more guidance without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has an output schema but the description does not reference it, leaving the agent unaware of what to expect as a return. It lacks prerequisites (e.g., that a fixture must be configured beforehand) and does not cross-reference sibling tools. For a mutation tool with no annotation support, the description is incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The only parameter, run_id, is not described in the description. With 0% schema coverage, the description does not explain what run_id refers to, how to obtain it, or its format. The description implies it identifies a replay-mode run but offers no elaboration, leaving the agent without sufficient meaning for the parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a clear verb ('Execute or resume') and resource ('replay-mode run'), and mentions the operator-configured fixture, which adds specificity. It distinguishes itself from siblings like alpha_run_stop and alpha_run_status by indicating it is the action tool. However, it does not clarify the distinction between executing a new run and resuming an existing one, which is a minor ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no explicit guidance on when to use this tool versus alternatives. It does not mention checking run status before resuming, or that this is the sole tool for starting replay runs. The context is implied but not stated, and there are no exclusions or alternative references.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

alpha_run_reportB
Read-onlyIdempotent

Render the deterministic Markdown report for one existing run.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
run_idYes
markdownYes
automatic_submission_availableNo

TDQS

B3.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, covering the safety profile. The description adds the 'deterministic' trait, which conveys that the same run_id always produces the same report—valuable context beyond the schema. It also implies the run must exist, though it doesn't elaborate on error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no redundancy. The core purpose and key trait ('deterministic') are front-loaded, making it immediately scannable. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has an output schema, so return values need not be explained. The description covers the essential semantics: a deterministic Markdown report for an existing run. It could be more explicit about error cases (e.g., run not found) or prerequisites, but given the low complexity (1 param) and strong annotations, it is reasonably complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate for the single parameter run_id. It implies run_id identifies the run ('one existing run'), but does not explain format, constraints, or any additional semantics beyond the schema's type and title. This is minimal compensation for a parameter with no schema-level description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Render') and a specific output ('deterministic Markdown report') for a targeted resource ('one existing run'), making the tool's purpose clear. It implicitly differentiates from siblings like alpha_run_status or alpha_run_stop by focusing on report generation rather than lifecycle operations, though it doesn't explicitly name alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus its siblings. The description does not mention conditions for use, when not to use it, or alternative tools that might be more appropriate, leaving the agent to infer context from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

alpha_run_statusB
Read-onlyIdempotent

Read the persisted status and counts for one existing research run.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
run_idYes
statusYes
stop_reasonYes
adapter_modeYes
distinct_candidatesYes
simulation_attemptsYes
automatic_submission_availableNo

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the description need not repeat these. It adds context that the tool reads persisted data (status and counts) and requires an existing run, but does not disclose error behavior for missing runs or permission requirements. The description does not contradict annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, focused sentence that conveys the core purpose without unnecessary detail. It is appropriately sized and front-loads the key information about reading status and counts for a specific run.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the output schema exists and annotations cover the safety profile, the description is fairly complete for a read-only tool with one parameter. It does not mention error handling (e.g., what happens if run_id does not exist) or whether the run must be in a specific state, but these are minor gaps given the simplicity of the operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has one parameter (run_id) with zero description coverage. The description implies run_id identifies the specific run, but provides no format, constraints, or additional semantics. While the purpose is inferable, the description does not fully compensate for the lack of schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (read) and the resource (persisted status and counts for one existing research run). It distinguishes itself as a targeted read for a specific run, but does not explicitly differentiate from sibling tools like alpha_run_report or alpha_run_stop. The verb and scope are specific enough for an agent to infer the tool's role.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no explicit guidance on when to use this tool versus alternatives. The description implies it is for checking status, but does not mention alternatives or conditions for selection. An agent would need to infer from context which sibling to call. No exclusions or prerequisites are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

alpha_run_stopB

Persist a fixed MCP-requested stop reason for one existing run.

ParametersJSON Schema
NameRequiredDescriptionDefault
run_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
run_idYes
statusNo
stop_reasonNo

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate this is a mutation (readOnlyHint=false) and non-idempotent, but the description adds no additional behavioral context. It doesn't clarify side effects such as whether the run's status changes, whether the stop is permanent, or if any permissions are required. For a mutation tool, this is a significant gap beyond what annotations provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that front-loads the action and immediately clarifies the target. There is zero waste; every word contributes to meaning, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one required parameter) and the presence of an output schema, the description doesn't need to detail return values. However, it lacks essential behavioral context for a mutation: what exactly does 'persist a stop reason' do to the run? Does it mark it as stopped? Is it reversible? These gaps make it incomplete for an agent needing to anticipate consequences.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema defines a single run_id with no description (0% coverage). The description adds the word 'existing', implying run_id must refer to a valid run, which provides some semantic context. However, it doesn't explain the format, expected source, or error behavior for invalid IDs, so it only partially compensates for the schema's lack of detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Persist a fixed MCP-requested stop reason') and the target resource ('one existing run'). It distinguishes itself from sibling tools like alpha_run_status (status), alpha_run_report (report), and alpha_replay_execute (replay) by being the only stop operation, so an agent can confidently identify its purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, nor any conditions or exclusions. It does not mention that alpha_run_status or alpha_run_report might be better for checking state, or that this is the tool for halting a run. The implied usage is clear from the verb, but explicit routing is absent.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.5.0
    • First observedalpha_method_cards_list
    • First observedalpha_replay_execute
    • First observedalpha_run_report
    • First observedalpha_run_status
    • First observedalpha_run_stop

TDQS

B3.4/5.0

Scored across 5 tools

Disambiguation5/5

Each tool targets a distinct resource and action: run stop, run status, run report, method-card listing, and replay execution. Even the three run_* tools are clearly separated by whether they write state, read status, or render output.

Naming Consistency4/5

All names consistently use the alpha_ prefix, snake_case, and an object_operation structure. Minor inconsistency remains because stop, list, and execute are true verbs while status and report are nominalized operations.

Tool Count5/5

Five tools is a well-scoped size for this server's purpose. Each tool covers a distinct function with no apparent redundancy.

Completeness4/5

The set covers the core run workflow: execute/resume, stop, status, and report, plus method-card listing. However, there is no run-listing tool and no method-card detail or mutation tools, so agents must already know run IDs to operate effectively.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    A
    maintenance
    Enables coding agents to query, compare, and audit local profiler traces, benchmarks, memory captures, and execution evidence without uploading code or data, using CLI and MCP interfaces.
    111
    115 PyPI
    114
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides LLM clients with market intelligence tools over stdio, including market snapshots, price history, sentiment scoring, evidence search, and research briefs, with saved-run resource access.
    AGPL 3.0