dsh-forecast-penalty
其他 活跃维护

dsh-forecast-penalty

PerryLink/dsh-forecast-penalty

依据电力市场考核办法与并网调度协议,自动比对预测偏差与考核台账,输出差异清单,仅提示不一致项,不做定性判断,方便人工复核。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
2
Open Issues
TypeScript
主要语言
NOASSERTION
开源协议
797 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:PerryLink/dsh-forecast-penalty
git clone https://github.com/PerryLink/dsh-forecast-penalty.git
git clone git@github.com:PerryLink/dsh-forecast-penalty.git
README.md main

dsh-forecast-penalty — Forecast-accuracy assessment register and assessment-charge arithmetic verification

English · 简体中文 · Español · Português · हिन्दी

What it is — Forecast-accuracy assessment register and assessment-charge arithmetic verification. It returns a list of what is inconsistent, where, and what to fix.
Who it is for — contract and settlement staff; no command line required.
What you give it — the source material the check works on (a table, register or document); the original is never modified. Excel can be converted to JSON/YAML first, in chat if the platform supports it.
What it does not do — no compliance verdict, no liability finding, no replacement for the reviewer; differences only.
How to start — search "Tender Compliance Suite" in WorkBuddy / Coze (this check is one part of it; availability as listed); or:
dsh plugin --profile <name> add dsh-forecast-penalty

DSH Market
dshfind

dsh-forecast-penalty reads one forecast-accuracy assessment register — the subject header plus one row per assessment period — and verifies that register's own completeness and arithmetic: that the period, the subject and the market are identified, that the forecast, actual and accuracy figures parse as numbers, that the stored accuracy agrees with the definition formula you configure and the assessment charge with the charge formula you configure, that the currency is written as a three-letter code, that no assessment period repeats, and that no unreplaced placeholder survives in the remark column. Every check that cannot run is reported in skipped with its reason.

Install

dsh plugin --profile <name> add dsh-forecast-penalty
dsh --profile <name> --dump-config | grep 'dsh-forecast-penalty'

What it looks like

Workflow diagram for dsh-forecast-penalty: call → plugin → result.

Workflow overview: call → plugin → result. The examples below use the real command surface.

What it answers

Examples

The table below is the example set: the first row is the detailed walkthrough, the remaining rows are short cases.

Detailed output

Tool forecast_penalty

Input

{"rows":[{"考核期":"2026-03","预测值":"待补","实际值":"1000"}]}

Output

{
  "id": "dsh-forecast-penalty.FP-002.de09b5a6",
  "ruleId": "FP-002",
  "severity": "warn",
  "locator": {
    "field": "forecastValue",
    "row": 1
  },
  "found": "第 1 行「forecastValue」的值「待补」无法解析为数字",
  "expected": "「forecastValue」应填写数字",
  "fix": "预测值应填写数字;本条只核对可解析性,不判断预测是否准确"
}

Observed from tests/fixtures/FP-002/FP-002-unsafe.json (cases.json expects FP-002 count 1); run via lib/index.mjs rules/forecast-penalty.yaml

You ask What it answers
The register never says which station or which market it covers, and one forecast figure reads --. FP-001 requires the subject and the market to be identified, and FP-002 requires the forecast figure to parse as a number; a -- is reported. FP-001 checks that the two are filled in, not that the station name is the right one, and FP-002 does not decide whether the forecast was accurate.
The accuracy I store differs from my own market's definition formula, and the charge differs from base times unit rate. FP-003 compares the stored figure with the definition formula configured in the rule pack — the shipped expression is one common convention and an example, not your market's rule, so replace expression or disable the rule — with a 1.5-point tolerance. FP-004 compares the charge with 考核基数 × 考核单价 at a 0.01 tolerance; the base is entered by you. Neither decides whether the assessment method applies or whether a charge should be levied.
The currency column is blank on some rows and says 元 on others. FP-005 requires a three-letter uppercase code such as CNY or USD, so a blank and a 元 are both reported; the rule's limit is that it judges the format only and does not decide which code your institution should use for the renminbi. It also does not decide whether the currency chosen is the right one.
The same assessment period appears on more than one row. FP-006 reports a period that repeats, because a duplicate makes the charge accumulate twice and leaves it unclear whether the period was registered twice or assessed twice; the comparison ignores whitespace. One period assessed by time block and band legitimately produces several rows — distinguish those in the remark column or by a different period identifier, or disable the rule. It does not decide which row is the duplicate.
The remark column still holds 【】, XXX or TBD. FP-007 reports the row when the remark column contains one of the placeholders configured in the rule pack, because a register copied from a template invites the reader to assume the assessment was actually carried out. The terms list is yours to adjust, and the rule does not decide whether the remark text is true.
A whole column is missing from my material — does the rule quietly pass? No. The column-level rules (FP-002, FP-005, FP-006, FP-007) report themselves under skipped with the reason that the material carries no such column, and the report distinguishes that from a rule that ran and found no differing row. A check that never ran is never presented as a pass.

Standards it follows

Document Number Cited by rules
电力市场考核办法与并网调度协议(无国家标准) 无统一标准(本条依据为台账可追溯性) FP-001
电力市场考核办法与并网调度协议(无国家标准) 无统一标准(本条依据为算术可行性) FP-002
电力市场考核办法与并网调度协议(无国家标准) 无统一标准(本条依据为本机构配置的准确率定义式) FP-003
电力市场考核办法与并网调度协议(无国家标准) 无统一标准(本条依据为本机构配置的考核算式) FP-004
《表示货币的代码》 GB/T 12406—2022(表示货币的代码;2022-12-30 发布并实施;全部代替 GB/T 12406—2008(该版名称为「表示货币和资金的代码」)——注意旧版名称含"资金";修改采用 ISO 4217:2015,非等同采用;条号本次未取得) FP-005
电力市场考核办法与并网调度协议(无国家标准) 无统一标准(本条依据为台账唯一性) FP-006
电力市场考核办法与并网调度协议(无国家标准) 无统一标准(本条依据为台账真实性) FP-007

Boundary: this plugin checks a 预测准确率考核台账 for arithmetic — that the period and subject are
identified, that forecast and actual figures parse, that the accuracy figure matches the definition formula
you configure, that the assessment charge matches your charge formula, that the currency follows its format,
that periods do not repeat, and that no placeholder survives. It does not decide whether a charge should be
levied, whether accuracy passes, or whether a waiver or appeal applies. Those depend on the market rules, the
exemption cases and the dispute procedure.

⚠️ This is a market rule, not a national standard — and the pack says so

The accuracy definition, the exemption threshold, the unit rate and the settlement basis are set by each
power market's assessment rules and the grid-connection dispatch agreement
. Provinces differ sharply (some
use 1 − deviation, some use root-mean-square error, some assess by time block and band), and no unified
national standard exists
. So this pack does not fabricate a standard number: every rule's excerpt states
plainly that its basis is arithmetic self-consistency or a locally configured convention and that no
citable clause exists
.

Two formulas ship as examples, and both are marked as such:

  • FP-003 accuracy defaults to 预测值 ÷ 实际值 × 100 with a 1.5-point tolerance. That is one common
    convention, not any market's rule
    . Before use, replace expression with the formula from your market's
    rules — or disable the rule. The note spells this out.
  • FP-004 charge checks 考核费用 = 考核基数 × 考核单价. The base is entered by you after working
    it out under your market's rules, because the threshold, the bands and the volume basis are the market's
    business and this plugin will not derive them. No unit rate is built in anywhere.

A consequence worth knowing: the accuracy rule ships at info severity precisely because its formula is a
deployment choice rather than a verified requirement.

Compatibility

Surface Status
Harness Peer range >=0.1.2-rc.1 <0.2.0 \|\| >=0.2.0-0 <0.3.0 — verified to accept both 0.2.0-rc.2 and 0.2.1-rc.2. engines.dsh is declared as >=0.2.1-0 <0.3.0 and is enforced by the host since 0.2.1
Node ^22.19.0 || >=24.0.0
Platforms All (plain ESM; no native code, no network, no model call)
Tool mode Works in native and ptc; for a year of periods use ptc

What it does

Registers the forecast_penalty tool. It reads one assessment register — the subject header plus one row per
period — applies a versioned rule pack, and returns a report.

Rule Check Severity Basis
FP-001 the register names its subject and market warn traceability
FP-002 the forecast figure parses as a number warn arithmetic feasibility
FP-003 accuracy matches your definition formula info local formula
FP-004 the charge matches your charge formula info local formula
FP-005 the currency is a three-letter code warn GB/T 12406
FP-006 assessment periods are unique warn register uniqueness
FP-007 the remark column holds no unreplaced placeholder warn register integrity

Configuration

Key Type Default Description
rulesFile string rules/forecast-penalty.yaml Rule-pack path, relative to the package root
disabledRules string[] [] Rule ids to stop running; each appears in skipped
onlyRules string[] [] Run only these rule ids; empty runs every rule
skipNotes string "" Note appended to every skipped reason
timeoutMs number 120000 Cooperative tool timeout budget

Rule-level parameters worth knowing:

  • FP-003 expression — the accuracy definition. Ops are divide, product, sum, subtract (first field
    minus the rest) and percent (first field ÷ second × 100), with an optional scale multiplier. tolerance
    defaults to 1.5 points; set it to your rounding convention.
  • FP-004 expression / tolerance — the charge formula, 考核基数 × 考核单价 by default with a 0.01
    tolerance.
  • FP-005 pattern — the currency shape; three upper-case letters by default.
  • FP-007 terms — the placeholders to look for.

Material format

The tool accepts JSON or YAML:

subject: 某某风电场
market: 省内现货
rows:
  - { 考核期: 2026-03, 预测值: '966', 实际值: '1000', 准确率: '96.60',
      考核门槛: '95', 考核基数: '80', 考核单价: '50', 考核费用: '4000', 币制: CNY }

Column names are matched case-insensitively and ignoring spaces, underscores and hyphens; the register's own
column names are kept, so a finding names the column it read. Numeric cells may carry thousands separators and
a percent sign.

Rule sources

Rule data lives in rules/forecast-penalty.yaml. Because the assessment regime is a market rule rather than a
standard, the pack's basis entries say so explicitly instead of citing one; the only external reference is
the currency-code standard, whose excerpt admits the clause text was not obtained. The load-time guard still
requires a document, clause, excerpt and source per rule, and still forbids a locally configured check from
being error.

Troubleshooting

  • FP-003 fires on every row. The accuracy figure was computed under a different formula than the one
    configured. Replace expression with your market's, or disable the rule — do not widen the tolerance to
    hide a definition mismatch.
  • FP-004 reports itself as skipped. The register carries no 考核基数 column, or no charge. The base is
    yours to compute and record; the plugin will not derive it.
  • FP-005 fires on 元. The default pattern wants three upper-case letters. Narrow or widen it to match
    your settlement documents' convention.
  • FP-006 fires twice on one period. That can be legitimate for time-block assessment (peak/flat/valley
    rows). Distinguish the rows in the period column or say so in the remark.
  • The plugin installs but the tool never appears. Check that main resolves to lib/index.mjs and
    that pnpm run build produced it; a wrong main makes the loader skip the entry silently.
  • dsh plugin add refuses the package as incompatible. The peer range covers 0.1.x and 0.2.x; if
    your runtime sits outside it, grant an explicit exemption:
    dsh plugin --profile <name> allow-version dsh-forecast-penalty@0.1.0 --dsh-version <runtime> --accept-risk
  • check reports manifest-peers as failed. The static checker compares against a hard-coded peer
    range that predates the 0.2 line. The runtime enforces peer compatibility at install time, so the
    declared range is the correct one; this is a known upstream issue in dsh-plugin-dev.

Development

pnpm install
pnpm run typecheck   # tsc --noEmit
pnpm test            # vitest, the shared table-plugin suite plus paired fixtures
pnpm run build       # tsdown -> lib/index.mjs + lib/index.d.mts
node ../scripts/sync-shared.mjs dsh-forecast-penalty   # refresh src/shared from ../_shared

The plugin is data-only: src/model.ts declares the table shape, the shared kit supplies the reader and
the check engine, and the rule pack declares every check.

PerryLink DSH Plugin Family

Full family index: choose a checker by material and all plugins. This repository is one of them.

License

Apache License 2.0 © 2026 dsh-forecast-penalty contributors.