LAwLi3tCoding/dsh-approval-review ↗★ 0

dsh-approval-review

提供独立复核裁决的自动审批功能 适合需要对 Agent 工具调用进行安全合规审查与自动决策的系统。

包名
dsh-approval-review
兼容性
待验证
Harness 依赖范围
>=0.1.2-rc.1 <0.2.0 || >=0.1.5-alpha.1 <0.2.0
Cordis 依赖范围
^4.0.2
版本
0.5.1
许可证
NOASSERTION
最近更新
2026年9月20日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:LAwLi3tCoding/dsh-approval-review

Configuration

All tunables live in the bundle's cordis.patch.yml row, so they are changeable without touching code. An id-targeted override replaces the whole config row — restate every key you still want, or the omitted ones silently return to their schema defaults.

KeyDefaultMeaning
enabledtrueMaster switch. false mounts the plugin but claims nothing.
enabledByDefaulttrueSession-start default for the runtime switch.
reviewTools['*']All tool approval requests by default.
defaultPolicyaiFallback routing policy for unmatched tools.
rules[]Ordered {pattern, policy, field?, note?} regex rules, evaluated before the tool table. field is reason (default), toolName, or arguments.
reviewer.enginellmWhich engine answers: the original LLM reviewer, or TypeSafe's Jev. See Reviewer engines.
reviewer.modedirectIsolated model call by default: no inherited parent prompt, history, skills or memory. Optional subagent can inspect the workspace. Applies to engine: llm only.
reviewer.provider / .model(inherit)Reviewer route; unset inherits the calling agent's own route.
reviewer.subagentProviderspawnOptional subagent backend; spawn omits parent history but still inherits the host preset.
reviewer.inspectLocalStatetrueEnable the bounded local inspector in direct mode.
reviewer.tools[read, glob, grep]The reviewer child's tool allow-list. An empty list falls back to the read-only default rather than the parent's whole face.
reviewer.timeoutMs120000Hard deadline for one reviewer call. A slow route plus a reasoning reviewer can take ~50s; a deadline that expires mid-review becomes a failure-policy outcome (a delegation to the human by default), not a verdict.
reviewer.maxTokens(model route default)Optional output cap; omitted by default so the adapter/model configuration applies.
reviewer.temperature0Sampling temperature.
reviewer.policyText(shipping policy)Replaces the ruling policy text.
reviewer.guidance(none)Extra deployment guidance appended after the policy.
reviewer.argumentMaxChars4000Per-string argument cap.
reviewer.argumentsBudgetChars16000Whole-argument-document cap; 0 disables.
context.turns2Prior turns of transcript evidence; 0 omits recent transcript; selected original/latest user intent is still supplied.
context.maxChars6000Transcript character budget.
context.includeAssistanttrueInclude assistant messages in the transcript.
context.includeToolActivitytrueInclude tool calls and results.
maxAutoAllowRiskhighHigh risk also requires medium/high authorization and bounded scope; critical risk is always denied.
onRiskExceededdelegateallow / delegate / deny above that ceiling.
onUncertaindelegateReviewer reported it could not decide.
onReviewerFailuredelegateReviewer crashed, timed out, or answered off-schema. Defaults to delegating: a reviewer that could not run is an infrastructure problem, not a verdict — set rejected for the fail-closed stance.
budget.maxReviewsPerTurn20Reviewer calls per open turn.
budget.onExhausteddelegatedelegate / deny once spent.
maxFailuresPerTurn10Reviewer failures per open turn before requests delegate.
verdictCache.ttlMs0Disabled by default. Opt-in only for direct mode with context.turns=0 and inspectLocalState=false; key includes session, user evidence and model.
verdictCache.maxEntries256Cached fingerprints before oldest-eviction.
circuitBreaker.consecutiveDenials3Consecutive denials that trip the breaker.
circuitBreaker.windowDenials10Denials within windowSize that trip it; 0 disables.
circuitBreaker.windowSize50Rolling window size.
circuitBreaker.actionstopStop the host turn after recording the refusal; delegate / deny remain available.
override.ttlMs300000How long an /approval-review approve stays usable; 0 never expires.
override.maxPending10How many recent denials the override can address.
reasonMaxChars2000Cap on any reason string the plugin emits.
feedReasonToModeltrueAppend the rationale to the refused tool result.
recordAllowedVerdictstrueAppend the allow verdict to the accepted tool result, so the card can show why an action was allowed. Costs one short marker block in the model context per auto-allowed call.
languageautoProse language this plugin emits: /approval-review command output and the reviewer's reason/suggestion fields. auto follows the harness language setting (Settings → General → Language), en/zh pin it. Resolved per call, so a switch applies to the next command and the next verdict. Boundaries: the decision/risk enums stay English tokens (the parser validates them), and text already recorded in the transcript — an earlier verdict's prose, an earlier command's output — is never rewritten.

Reviewer engines: llm and jev

reviewer.engine chooses who answers a review. llm (the default) is the original path: one model call — or a read-only subagent — reads the evidence packet and returns the verdict JSON. jev posts the same packet to TypeSafe's System One endpoint and reads typed answers back, with the decisions (prohibition hit, uncertainty, bounded scope) applied in code. Everything downstream of the verdict — the risk gate, the breaker, the cache, the ledger and the card — is shared by both engines.

Jev never touches DSH's model routes: it is a direct HTTP call with a bearer key, so it does not appear in the model picker and needs no provider registration. The typesafe/ value shown in the ledger is a label the plugin synthesizes for its own audit record, not a DSH route; /approval-review model still works and overrides the model name or version sent to TypeSafe.

A selection from the picker carries its engine: typesafe/ reviews with Jev, / reviews with that LLM route, a bare `` keeps the engine already in force and replaces only the model, and default returns to the deployment's own reviewer. That is what makes every listed row mean something — including switching a Jev deployment back to an LLM for one session, which the header pill and the ledger both follow. Two limits hold: a session may switch to Jev only when the deployment acknowledged egress (jev.allowEgress), and the Jev endpoint receives a bare model name, so a value that still contains / after the typesafe/ marker is stripped is reported and ignored rather than forwarded.

KeyDefaultMeaning
reviewer.jev.endpointhttps://api.typesafe.ai/v1/systemoneWhere the evidence is POSTed. Point it at your own gateway if the packet must not go upstream directly.
reviewer.jev.modeljev-latestModel or alias. The response reports the version that answered (jev-1.13.0), and that is what the ledger records.
reviewer.jev.apiKeyEnvTYPESAFE_API_KEYEnvironment variable holding the key. The key is never read from config, never logged, never written to the audit record.
reviewer.jev.timeoutMs8000Deadline for the single HTTP call; independent of reviewer.timeoutMs.
reviewer.jev.permitProbMin0.6Top probability below which the permit answer counts as uncertain.
reviewer.jev.prohibitedAt0.5Probability at which any of the four prohibitions refuses outright, regardless of authorization. Deliberately asymmetric: a false refusal is cheaper than a false allow.
reviewer.jev.scopeBoundedAt0.5Probability at which the scope answer counts as bounded.
reviewer.jev.allowEgressfalseMust be true for the plugin to mount. Otherwise loading fails and names the endpoint the evidence would reach.
reviewer.jev.rubric{}Per-question instructions overrides keyed by question id (see src/jev-questions.ts).

What differs in practice:

  • One HTTP call per review, no tool loop. Jev cannot inspect local state, so a request whose decisive fact is not in the evidence becomes uncertain and follows onUncertain (a human prompt by default) instead of being investigated. reviewer.mode and reviewer.inspectLocalState do not apply.
  • reason is composed in code from the answers — for example Denied: prohibition "disclosure of secrets or private data" (0.97); risk critical; authorization unknown; permit 1.00 — in the configured output language. reviewer.policyText does not apply: the ruling policy lives in the per-question rubric.
  • The evidence packet leaves the machine, which is what allowEgress acknowledges. Redaction is unchanged (key-name based, plus a best-effort pass over unparsable payloads); it does not scrub secrets out of free text.
  • The key is resolved through the harness credential store first, then the environment. Store it in the credential settings, in $DSH_HOME/.env, or export it before launch: the credential seam already layers those sources (launch environment → managed store → project .env → harness-home .env) and re-resolves per request, so a rotated key applies to the next verdict without a restart. A GUI-launched harness never runs your shell startup files, which is why the store — not ~/.zshenv — is the place that works.

What happens when Jev is not configured, or only half configured:

StateResult
reviewer.engine left at llm (the default)The LLM reviewer runs. No request reaches TypeSafe, no key is needed, and no Jev warning is logged.
engine: jev without jev.allowEgress: trueThe plugin refuses to mount, naming the endpoint the evidence would reach. Nothing is reviewed automatically.
engine: jev, egress acknowledged, but no key resolvable from the store or the environmentThe plugin mounts and warns at startup when no credential store is mounted; with a store, the first review fails with a missing-credential message instead. Either way the failure follows onReviewerFailure — delegate by default, so the request reaches a human instead of being silently allowed. After maxFailuresPerTurn failures the turn stops consulting the reviewer at all.
engine: jev with mode: subagent, or a non-https endpointThe plugin refuses to mount.
Key rejected (401/403), rate limited (429), 5xx, timeout, non-JSON, or a missing answerRecorded as a reviewer failure; no retry and no partial answer is acted on.
Session access mode is not reviewerPresetThe plugin claims nothing, by design — the ledger stays empty and /approval-review status names the gate.
Enabling Jev on a fresh install
  1. Store the key where the harness can resolve it: the harness credential settings, or $DSH_HOME/.env as TYPESAFE_API_KEY=…. Both are read per review; process.env is the fallback for a deployment that mounts no credentials row.

  2. Turn the engine on in your profile patch. An id-targeted override replaces the whole row config, so restate any key you still want:

    - id: approval-review
      config:
        reviewer:
          engine: jev
          jev:
            allowEgress: true
    
  3. Restart the harness (the engine is read at mount) and run /approval-review status: it prints the engine, the gate and the model, so a silent ledger always has a visible cause.

Verify connectivity before enabling it — the live probe sends synthetic evidence only, never repository content:

export TYPESAFE_API_KEY=…     # the same key the plugin resolves at review time
npx vitest run tests/jev-live.test.ts tests/jev-policy-live.test.ts

Tool policies

  • ai — this plugin's reviewer decides. allowed-once or rejected.
  • human — delegate with next() to the rest of the answerer chain: the ordinary approval prompt. The plugin never short-circuits it.
  • never — deterministic rejected with an explanatory marker, no reviewer call and no prompt. The hard-disable stance for a tool family.

edit is deliberately not in the default reviewTools: in-place modification of an existing file is the highest-consequence routine action, so it keeps the human prompt until a deployment decides otherwise.

Example: stricter deployment

- insert:
    - id: approval-review
      name: dsh-approval-review
      config:
        reviewTools: ['bash', 'pwsh', 'write', 'edit']
        defaultPolicy: human
        rules:
          - pattern: '(?i)(rm\s+(-[a-z]+\s+)*/|git\s+push\s+--force)'
            policy: never
            note: destructive
          - pattern: 'curl|wget|nc\s'
            policy: ai
            field: arguments
        reviewer:
          model: ''
          timeoutMs: 30000
        maxAutoAllowRisk: low
        onRiskExceeded: delegate
        circuitBreaker: { consecutiveDenials: 2, windowDenials: 5, windowSize: 20, action: deny }