Preface¶
When performing database Q&A or operational root cause analysis with DSH, common practices include stuffing table schemas directly into prompts or letting the model guess column names and business logic. When there are many tables and terminology doesn’t align with physical fields, SQL and evidence chains easily drift. DLR (Decoupled Logic Representation) decouples the logical concept layer from the physical data layer and mounts knowledge hierarchically along governance lines within TSM (Three-Level Semantic Modeling). The repository also provides a TypeScript semantic service (LanceDB + Neo4j) and a bundle for DSH: dsh-tsm-agent. The following introduces what it is, what it can do, and how to connect the backend with DSH locally.
What is this¶
DLR is a semantic modeling paradigm oriented towards data sources: a two-layer model (LE Logical Entity / PE Physical Execution/View) combined with ARCS (Projection Anchoring) and PAS (Semantic Routing) allows agents to stably map natural language questions to relational databases. The project operates within the TSM framework, with three levels: L1 dlr (Data Source Level), L2 consensus (Domain Consensus), and L3 sop (Business Logic/SOP); whether knowledge enters a specific level is determined by governance lines.
Maintained by ljwzhaoxiaoniu, it is categorized under Model Reasoning in the SkillHub directory. The current bundle version is v0.2.2 (npm package dsh-tsm-agent). The repository is delivered via multiple npm packages: semantic core tsm-core-dlr, DSH suite dsh-tsm-agent, evaluation dsh-tsm-eval, as well as two switchable scenario packages for BIRD mini-dev and Cloud-OpsBench.
- Directory Page: https://www.skillhub.cn/plugins/ljwzhaoxiaoniu/DLR
- Source Code: https://github.com/ljwzhaoxiaoniu/DLR
Core Features¶
Semantic Service (tsm-core-dlr)¶
A semantic backend implemented in TypeScript: LanceDB vectors, graph storage (in-memory or Neo4j), and ONNX encoder, exposing 7 MCP tools via streamable HTTP (including dlr capabilities; dlr-state scenarios have 3 additional ones). The default MCP address is http://127.0.0.1:28795/mcp, which can be overridden by the environment variable TSM_MCP_URL.
Once connected via dsh-tsm-agent, tools are registered on the DSH side as mcp__semantic-core__*, mainly including:
| Tool | Purpose |
|---|---|
dlr_semantic_query |
L1: Recall business entities (LE) involved in the question |
get_pe_mapping / get_le_attrs |
Physical view columns, ARCS, database_url |
dlr_search_consensus |
L2: Consensus entries for terms and columns/values |
dlr_search_sop |
L3: Retrieve caliber/logic sections based on the question (returned if available) |
get_full_data_info |
Physical column info beyond views |
execute_sql |
Read-only SQL (subprocess, 20s timeout) |
DSH Bundle (dsh-tsm-agent)¶
The bundle connects the profile to the running TSM Core Service and includes scenario-independent paradigm skills, a web status overlay, and agent rules (AGENTS.md). Contributed top-level lines include:
mcp-semantic-core: MCP client pointing to the semantic service (toolCallTimeoutMs: 60000,failOnStartupError: true)dlr-status: Web overlay displaying backend health and semantic asset counts- Agent preset
preset-dlr: Persona, AGENTS.md, skills, and compaction (for interactive sessions; headless does not attach the preset, but the MCP top-level line remains effective)
The hard dependency tsm-core-dlr is installed with the package (including native dependencies, roughly 200 MB); the service process still needs to be started separately. Scenario data comes from optional tsm-scenario-* packages, pointing to the package name or a self-contained scenario path via TSM_SCENARIO. The bundle itself is decoupled from specific datasets.
Evaluation and Benchmark Scenarios¶
dsh-tsm-eval: Runs scenario exam papers using dsh headless, scores withtsm grade, and generates reproducible reports (results, processes, session logs).tsm-scenario-birdmini: BIRD mini-dev (11 databases / 500 questions), public score 500/500 verdict correct (426 entries exactly match gold, 74 ruled on dataset gold defects under L3 clauses).tsm-scenario-cloudopsbench: Cloud-OpsBench (754 Kubernetes RCA cases), JRA 753/754 (99.87%); fully closed evidence chains 740/754 (98.1%). The above benchmarks run end-to-end under the repository architecture, with an auditable per-question ledger.
The model combination in public materials is DeepSeek-V4.1-Flash + TSM+DLR; the BIRD 500-question batch run was produced on an earlier dsh 0.1.7-alpha.1. The author noted in the npm description that it was not rerun after upgrades; after upgrading dsh, you should use --dump-config to verify configuration lines first.
Installation and Activation¶
Environment requirements (excerpt from repository Quickstart):
| Item | Description |
|---|---|
| Node.js + npm | Service runs in TypeScript, commonly using npx tsx / node; dsh-tsm-agent requires Node >= 20 |
| Neo4j 5.x | Local or any Bolt endpoint, configure NEO4J_HOME or NEO4J_URI |
| ONNX Encoder | Run bash "TSM Core Service/scripts/fetch-model.sh" within the checkout (approx. 95 MB) |
| dsh | Documentation example uses @deepseek-ai/dsh@0.2.0-rc.2 (alpha) |
| API Key | Copy DSH-based Agent Service/dsh_dlr/.env.example to .env and fill in DEEPSEEK_API_KEY |
Installing the bundle (once per profile). It is recommended to use the DSH plugin manager (Settings → Plugins → Install bundle) or the agent’s plugin_manager tool (install_bundle), which will complete the installation and selection of the bundle simultaneously. If using the CLI to only install the package, you still need to enable it in the plugin manager or add the package name to the profile’s dsh.profile.bundles:
dsh plugin --profile web add dsh-tsm-agent
If you have a local checkout, you can install from a local path (replace the path with your checkout location):
dsh plugin --profile web add "<repo>/DSH-based Agent Service/dsh-tsm-agent"
Optional scenario and evaluation packages can be installed as needed, such as tsm-scenario-birdmini, tsm-scenario-cloudopsbench, dsh-tsm-eval; set TSM_SCENARIO=<package_name> when using them.
Starting the semantic backend. If you have a checkout, you can use scripts (idempotent, will launch Neo4j and TS MCP, port 28795):
bash "DSH-based Agent Service/scripts/start_backend.sh"
cd "TSM Core Service" && npx tsx src/verify/precheck.ts
precheck should list 7 tools. If installed only via npm without a checkout, you can install the core globally and start the service via CLI (initial setup requires fetching the model and running build for installed scenarios):
npm i -g tsm-core-dlr && tsm serve --http 28795
tsm fetch-model
tsm build
For an interactive web session, after configuring .env:
bash "DSH-based Agent Service/dsh_dlr/run_web.sh"
Typical Usage¶
Headless Single Question¶
Assuming the backend is started and the profile has the bundle installed and enabled, you can use the repository script to run a single question for BIRD mini-dev (the second argument is the natural language question):
bash "DSH-based Agent Service/dsh_dlr/run_one.sh" 1471 "Your natural language question here"
MCP is a top-level line; --profile headless does not attach preset-dlr, but semantic tools are still available.
Switching Scenarios¶
The scenario layer is pluggable: point TSM_SCENARIO to a tsm-scenario-* package containing self-contained three-level sources (and optional exam papers). After switching scenarios, follow the checklist in the repository docs/04-application.md to rebuild indexes and verify MCP tools and data paths.
Running Evaluation Papers¶
After installing dsh-tsm-eval, you can use its workflow to perform headless execution and tsm grade scoring on scenario papers, outputting reports with processes and session logs for comparison with benchmark ledgers (e.g., scenarios/birdminidev/DETAIL.md, scenarios/cloudopsbench/DETAIL.md).
Applicable Scenarios and Notes¶
Suitable for teams needing auditable relational database NL2SQL in DSH, or Cloud Operational Root Cause Analysis (with closed evidence chains): semantic assets and L1/L2/L3 layering are provided uniformly by the service. The model side mainly queries via MCP hop-by-hop rather than swallowing the entire schema at once.
Please note before use:
- Permissions: Plugins and bundles run with the current dsh process permissions; please read the GitHub Repository source code and the MIT license before installation, and confirm sensitive configurations such as API Keys, Neo4j, and dataset paths.
- Dependency Size and Service Separation:
tsm-core-dlrhas large native dependencies and must beserved separately; if the endpoint is unreachable, the MCP line will fail directly due tofailOnStartupError: true. - dsh is still alpha: The bundle has performed configuration probing on
@deepseek-ai/dsh@0.2.0-rc.2; after version changes, executedsh --profile web --dump-configto check ifmcp-semantic-core,dlr-status, andpreset-dlrare still present. - Data Preparation: BIRD mini-dev needs to be decompressed to
MINIDEV_sqlite/according to upstream instructions; the Cloud-OpsBench scenario package comes with graded sources and upstream scorer adaptations.
SkillHub (skillhub.cn) is a community plugin directory and has no official affiliation with DeepSeek / High-Flyer; inclusion information (such as star counts and benchmark figures in the introduction) may differ slightly from the GitHub README. Refer to the documentation you actually open and the scoring ledgers.
Conclusion¶
DLR + TSM decouples data source semantics, domain consensus, and business SOPs into a governable three-level structure, then connects to DSH’s MCP and presets via tsm-core-dlr and dsh-tsm-agent; two public scenario packages provide reproducible NL2SQL and K8s RCA benchmarks. If you want to try the same semantic gateway in the Harness, you can enter the instructions from the directory page, or install dsh-tsm-agent via npm directly and start the :28795 backend as described above.
- Plugin Directory: https://www.skillhub.cn/plugins/ljwzhaoxiaoniu/DLR
- GitHub: https://github.com/ljwzhaoxiaoniu/DLR