npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-harness2-task-recursion

v0.2.1

Published

Task-level recursion: Propose → Probe → Gate-v4 admission → ledger v3 → compose decisions.

Readme

dsh-harness2-task-recursion

npm 分发名:dsh-harness2-task-recursion;插件导出 name 仍为冻结的 harness2-task-recursion。

旧目录名:harness2-task-recursion。

任务级递归插件(dsh 0.2.1-rc.2 / Cordis 4,第三轮冻结契约)。

入口契约

export const name = 'harness2-task-recursion'
export const inject = ['tools', 'llm', 'agents']
export const Config = Schema.object({ ... })
export function apply(ctx, config)

循环

失败信号(request-error / 同工具连续失败)
  → 同步调度后台 cycle(去重 + cooldown)
    1. Propose  ctx.llm.stream(失败重试一次;失败 → onError('propose-failed'),不伪造事件)
    2. Probe    每候选一个隔离子智能体;TrialRecord 携带 candidateId/component/operation/editContentHash
    3. probe/completed  先 append 账本 v3,成功后 emit(schema 校验失败/账本失败 → 不 emit)
    4. Compose  observeOnly → cost-limit → low-evidence → regression → apply
    5. compose/*  append v3 后 emit;applied 携带 appliedEdits(与 appliedCandidateIds 一一对应)
    6. 下一个 pre-step 仅 applyMode=pre-step-patch 时同步应用 pendingPatch

第三轮要点

  • TrialRecord 元数据三个字段必填;缺失 → onError('trial-metadata-incomplete') 并拒绝 probe/completed(Q1)。
  • ProbeMetrics.tokenCostSource:Propose 用 usage chunk;baseline/trial 优先 tokenMeter,否则估算;同一 metrics 单一来源(Q4)。
  • 账本 v3 envelope;readLedgerTail 接受 v2|v3 并内存映射,v2 文件不重写(Q7)。
  • ComposeRejectedPayload.rejectedCandidateIds 按 reason 构造,并保证 ∈ trials(Q3)。
  • 组件名来自 src/constants.ts(八类冻结),与 meta 包逐字节相同(R3-7)。
  • 第四轮:Propose 两次失败 → 终态事件 propose/failed(reason ∈ llm-error/schema-invalid/hash-mismatch/component-invalid、attempts=2、lastError、可选 baseline),账本 event='propose/failed',append 成功后才 emit 且与同 cycleId 的 probe/compose 事件互斥;rejectedCandidateIds 只取 trials 中出现过的 id(R4-2)。
  • TODO(ROUND2_APPLY)(运行时补丁 API)、TODO(ROUND2_SANDBOX)(Probe 沙箱)保留。

Round-6 PR-2(edit-body sidecar)

  • Config editsDir(默认空 → <dirname(ledgerPath)>/edits)。
  • Propose 后为所有候选写 harness2-edit/v1 内容寻址 body;写失败 fail closed。
  • apply 前 verifyEditBodies;缺失 → compose/rejected(compose-not-wired)。
  • gcEditBodies 删除过期未引用 body,legacy ledger 无 body → legacy-no-body。
  • candidateId 必须是 cand-<16 hex> 且与 (candidateType, component, content) 推导一致;verifyEditBodies 做 candidateId 一致性校验。

Round-6 PR-1(Gate-v4)

  • 新配置:gatePolicy: v4 | v3(默认 v4;v3 仅供归档 replay)、controlReplicates(默认 2)、maxAppliedEdits(默认 1)。
  • Gate-v4:admission ≠ certification;2 个真实 recovery control;deadband;tokenCost 只做 25% guard;control 缺失/不稳定 → low-evidence fail closed。
  • 仅 set-persona-prefix 可在 probe 内模拟(agent-scoped systemPrompt.section);其余 canonical 编辑 applicability:'unavailable',等待离线 applier。
  • Gate-v4 fail-closed:applicability 缺失即 unavailable;空 transcript trial 无效;completion 由 assistant 输出推导,且 completion 回归会拒绝。
  • matched control:每个可模拟候选 2 个长度匹配的 control(2 controls + 1 treatment/candidate);control 失败不跨候选重试;receipt 与 payload 的 rejected 集在 v4 中 audit-complete 且一致。
  • 白名单/deny lexicon/自调裁判键见 src/admissibility.ts;PROPOSE_SYSTEM 已改为 canonical operations。

验证

npm run build && node --test test/verify.mjs   # 28 项(含 admissibility、gate-v4、归档 replay、v4 正向路径、matched controls)
npm run stage0:r6                              # live Gate-v4 负向验收(需要 dsh 0.2.1 CLI)
npm run stage0:r6:positive                     # live Gate-v4 正向验收

Round-6 PR-3(offline applier)

  • 工具在仓库根 tools/harness2-apply/(独立进程,不 import 本插件源码)。
  • 消费 PR-2 的 <editsDir>/<hex>.json,plan → preflight → apply → rollback;--allow-unevaluated 仅 PR-4 前受控使用。
  • 不修改本插件的 ledger/bus/confidence/AppliedEdit。

Round-6 PR-4(Gate-B evaluation)

  • 评估工具在仓库根 tools/harness2-eval/(独立进程);applier apply 默认要求 accept harness2-eval/v1 报告。
  • 不修改本插件的 ledger/bus/confidence/AppliedEdit;fake-provider 仅校准,真实 provider 报告才用于生产 apply。