
Hybrid Recursive Ladder
io.github.MagicSquarekey由 GitHub 账号 MagicSquarekey 发布v0.0.6更新于 Oct 29, 2026
Aggregate long time-series ranges with a few source requests instead of one per bucket.
发布方自己的服务:CodeReclaimers Capability Oracle
概览
为受桶数限制的时序接口做查询规划,让助手用少量源请求完成长区间聚合,而不是每个桶查一次。
- 可以做什么
- 查看阶梯配置并把时间区间分解为日历分段
- 对一个或多个序列求和,可混合本地物化存储与数据源
- 逐段核对本地副本与数据源是否一致
- 在无需配置的内置演示数据上直接试用
- 适用场景
- 当助手需要从 ThingsBoard 这类按桶或按请求计费的时序接口汇总较长的分钟级或天级区间,逐桶查询太慢时适用;也适合需要本地副本并与源端核对、修复的场景。
- 运行要求
- 以 Python 包形式在本地通过 stdio 运行(uvx 或带 mcp 扩展的 pip),仅限桌面。演示模式无需任何配置。接入真实数据源需设置 HL_SOURCE 为 thingsboard 或 postgres,并提供 HL_TB_URL 及 HL_TB_TOKEN 或 HL_TB_USERNAME 与 HL_TB_PASSWORD,本地存储需 HL_PG_DSN。可选 HL_FINEST 与 HL_TIMEZONE。
安装
在 SourceWeft 中
- 打开 控制台中的 Hybrid Recursive Ladder,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Hybrid Recursive Ladder
Query planning for bucket-limited time-series APIs. Aggregate long ranges with a handful of source requests instead of thousands of per-bucket queries.
Languages: English · 简体中文 · 日本語 · 한국어 · Español · Français · Deutsch · Português · Русский · العربية · हिन्दी
Algorithm spec · API reference · Benchmarks · Related work · Public disclosure · Docs index
[CI] [License: MIT] [Python 3.10+] [Version] [Website] [DOI]
Same output granularity. The per-bucket client pays one round trip per row; the ladder fetches each level once.
Why this exists
Most time-series APIs charge you per request, per bucket, or per round trip. A naive "one query per statistical bucket" client turns a two-day minute-level range into 2,880 buckets, each needing up to four HTTP calls. In a production ThingsBoard deployment, 1,140 buckets took 139 seconds over a VPN.
The bottleneck is not arithmetic. It is the number of network round trips.
Three obvious fixes all sacrifice something:
The ladder takes a different route: keep the output granularity, but stop fetching one request per output unit. A source that can return an interval aggregate over a contiguous run can fill many output segments in one request.
How it works
- Decompose
[start, end)into complete calendar units, from month down to the configured finest level. Emit only complete units; push the partial left and right edges to the next finer level. - Group adjacent segments only when they need the same fetch level. Hours and minutes can share a minute-level run; months and days cannot.
- Fetch each maximal contiguous run once at the next finer aggregation: months as days, days as hours, hours as minutes, minutes as minutes.
- Fold the returned buckets into the output segments locally.
For 2026-01-01 00:00:00 → 2026-10-21 18:49:59, that is 97 segments instead
of 423,049 minute buckets. A typical 10-month query needs roughly 5–7
aggregation requests.
Rules
- Left-closed, right-open —
[start, end). - Complete units only — a month/day/hour/minute is emitted at its level only when it lies entirely inside the range.
- Recursive edges — a partial edge is pushed to the next finer level; a sub-minute remainder becomes its own tail segment.
- Local calendar — boundaries use the configured IANA timezone (default
Asia/Shanghai). - Tiling — segments are ordered, contiguous, non-overlapping, and their
union is exactly
[start, end).
Request bound
For a fetch run of duration T at bucket size Δ, with K buckets per request:
Fine-grained work is confined to the two partial units at the edges. For the
default hierarchy, N <= N_month + 639; recursion depth is at most 4. The
request count is O(N_month / K + 1) — it grows with the coarse units, not with
the number of minute buckets. The formal propositions are in
docs/algorithm.md §5.3–5.5 (中文).
Quick start
The demo builds synthetic 15-minute data, decomposes a 120-day range, materializes half of it, runs a local-first mixed query, and verifies that the totals match. No database, no network, no configuration.
Optional extras:
The core decomposition has zero third-party dependencies (only tzdata for
reliable IANA time zones on Windows).
Usage
Python library
The engine depends on two small protocols: TimeSeriesSource (interval_agg,
raw_series) and PointStore (sum_ranges, series, coverage,
upsert_points, ...). Built-ins: MemorySource/MemoryStore,
ThingsBoardSource, PostgresStore. See
docs/architecture.md (中文) to add another source.
CLI
HTTP API
The API uses {"code":0,"data":...} on success and {"code":1,"detail":...} on
error. Every endpoint is in docs/api.md (中文).
MCP server
Tools: ladder_meta, ladder_decompose, ladder_sum, ladder_verify. With no
configuration it serves demo data, so an agent can try it immediately. Example
client configuration:
Agent skill
Copy skills/hybrid-recursive-ladder/ into
your agent's skills directory (for example ~/.claude/skills/ or
~/.zcode/skills/). The skill teaches the agent when to use the ladder, how to
call the CLI/API, and how to interpret null vs 0.0 and source.
Local-first mode
When you have a local point store, the same segments are split against materialized coverage. Covered parts come from one batched local query; uncovered parts come from the source; a partially covered segment fetches only the missing slice.
Coverage is recorded only up to now - 5 minutes; the in-flight tail is never
trusted. A range is marked covered even when the source returned zero points
("we asked, there is nothing"). Before a rewrite, its coverage is cleared — a
failed pull cannot leave stale coverage pointing at incomplete data.
Verify compares the source (authority) with the local store segment by
segment, drilling only differing segments down to points (added / removed /
changed). Repair deletes the local range and re-pulls it from the source
in transaction-sized windows, then re-marks coverage.
Guarantees and limits
Every segment carries cnt (observed points/buckets), expected (buckets the
segment should contain, for source segments) and source (local, tb,
mixed, empty, uncovered). A low cnt relative to expected means sparse
data; the sum is still arithmetically correct, just based on fewer points.
Guarantees
sumis exact: the sum of all segments equals the sum of the source's points in the range. No approximation, no sampling.- Segments tile the range exactly; no zero-length segments.
nulland0.0are distinct everywhere.- Materialization is idempotent; overlapping runs cannot duplicate a timestamp.
- The algorithm only reads the source. It never writes to ThingsBoard.
Limits
- Sum only in v0.0.6.
avgneedssum+countweighting;meter_deltaneeds the first value of every segment (ThingsBoard has noFIRST), so those rules are not on the ladder yet. - Data completeness ≠ arithmetic correctness. Missing samples make the total
lower than the physical total;
cnt/expectedexpose this but do not impute. - ThingsBoard limits: ~700 buckets accepted, 800 rejected (the docs' 1000 is
unreliable); the adapter defaults to 500. Raw series are capped at 10,000
points per request.
COUNTcollapses duplicate points in the same minute. - In-process tasks are lost on restart; results are recomputable and materialized data is not lost.
- DST zones: calendar boundaries are supported, but fixed-size source
buckets mean day/hour folds are designed for fixed-offset zones such as
Asia/Shanghai. Usehourorminutefetching around DST transitions.
Historical fixes and version notes live in CHANGELOG.md.
Performance
From a production ThingsBoard deployment (numbers vary by network and data density):
See docs/benchmarks.md (中文) for methodology and caveats.
Positioning and prior art
This is a query-planning method for deployments where you can read an interval-aggregation endpoint but cannot write to or reconfigure the source. It is not a new time-series database, and not a new general theory of aggregation. It composes calendar mixed-radix decomposition, canonical interval decomposition, roll-up and multi-resolution aggregation.
The closest systems are RRDtool/Whisper (multi-resolution archives), BTrDB (hierarchical time-partitioned summaries), TimescaleDB hierarchical continuous aggregates, and Druid period granularity. Query-side systems such as Prometheus and Grafana choose one uniform step; the ladder plans multiple calendar levels in one query.
See Related work and positioning (中文) for the full comparison, the historical algorithms, and the defensible novelty statement. The method is published as a public disclosure (中文); a technical article walks through the production benchmark and the request-count argument.
Project, development and roadmap
Project layout
Optional PostgreSQL integration test:
Roadmap: avg and meter_delta rules; InfluxDB / Prometheus / ClickHouse
adapters; Celery/RQ task backend; OpenTelemetry metrics; PyPI trusted publishing.
Citation
Version DOI: 10.5281/zenodo.23683292.
Concept DOI for all versions: 10.5281/zenodo.23556605.
CITATION.cff provides the same metadata for GitHub's
"Cite this repository" button.
License
MIT © 2026 MagicSquarekey
来源:README.md,提交 4707cda
工具
0版本历史
1- v0.0.6最新Oct 29, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
其他 Recursive 集成

CodeReclaimers Capability Oracle
support.recursive官方发布者
让助手通过远程端点查询 CodeReclaimers LLC 咨询公司的技能、项目历史和可用性信息。

Recursive Support Oracle
support.recursive官方发布者
面向 Recursive AI 客服代理平台的远程 MCP 服务器,让助手查询产品信息、价格、功能,并提交功能请求。

DezignWorks Product Oracle
support.recursive官方发布者
让助手查询 DezignWorks 逆向工程软件的信息,包括功能、兼容性和价格。

GenPark Recursive JSON Schema Healer
由 GitHub 账号 alphaparkinc 发布
递归式 JSON schema 校验器与自主修复器,可修复类型不匹配、缺失的默认值,以及AI 翻译