Study-Mate
Miaotofu01
你的AI学习搭档:定路线、讲知识、做项目,边学边做,学透一门科目
PerryLink/dsh-research-core
REP v1 — the shared Research Evidence Protocol for DeepSeek Harness research plugins: JSON Schema + TypeScript types for sources, snapshots, anchors, evidence, claims, checks, artifacts, audit events and sealed report manifests, plus a zero-dependency content-addressed evidence store, canonical hashing, SARIF export and an independent verifier CLI.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:PerryLink/dsh-research-core
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
REP v1 — the shared Research Evidence Protocol for the DSH research plugin family.
One protocol, one store, one verifier. Every research plugin speaks the same evidence language, and anyone can recompute what it claims.
English · 简体中文
dsh-research-core is the shared layer under a family of 18 small, independently installable research plugins. It does three things and nothing else:
SourceRef, Snapshot, Anchor, Evidence, Claim, CheckResult, Artifact, AuditEvent and ReportManifest, wrapped in one ResearchRecord interchange file (.rep.json).ctx.researchEvidence) backed by a content-addressed store, plus a structural bridge to the existing dsh-research-report ledger (ctx.researchReport).plugin output ──► REP record (.rep.json) ──► dsh-rep-verify ──► verified / failed
│
├── schema/rep-v1.schema.json (the contract)
├── objects/<sha256> (immutable bytes)
└── manifest seal (sha256 of canonical JSON)
dsh-research-report. That plugin keeps ctx.researchReport and its byte-frozen assemble contract; core adapts to it and never rewrites it.| DeepSeek Harness | dsh-v0.2.1-rc.5 (verified on this machine, 2026-11-08) — npm peer line >=0.2.1-0 <0.3.0 \|\| >=0.2.2-0 <0.3.0 |
| Node | ^22.19.0 \|\| >=24.9.0 (tested on 24.22.1), ESM only |
| Peers | @deepseek-ai/cordis ^4.0.5-alpha.1, @deepseek-ai/schemastery ^3.18.5-alpha.1 |
| Runtime dependencies | zero |
# npm channel
dsh plugin --profile <name> add @perrylink/dsh-research-core
# git channel (pin a commit)
dsh plugin --profile <name> add github:PerryLink/dsh-research-core#<commit-sha>
# local checkout (development / smoke)
dsh plugin --profile <name> add file:/absolute/path/to/dsh-research-core
Verify the row mounts:
dsh --profile <name> --dump-config | grep dsh-research-core
Uninstall:
dsh plugin --profile <name> remove @perrylink/dsh-research-core
Mounting is optional for consumers: the package also works as a plain library (import { validateRep } from '@perrylink/dsh-research-core'), so a plugin can use REP without depending on the service being mounted.
| Entity | Purpose | Hard invariant |
|---|---|---|
SourceRef |
where evidence came from (doi / pmid / pmcid / arxiv / isbn / url / file / dataset / other) |
the id pattern is enforced per kind |
Snapshot |
immutable, content-addressed bytes | snapshotId = "sha256:<hex>"; path MUST equal objects/<hex> |
Anchor |
a locator into one snapshot (page / section / paragraph / char / table / figure / record) |
kind-specific fields and canonical value forms (p.3, c.10-40, para.7, t.2, f.1, field:title) |
Evidence |
source + snapshot(s) + anchor(s) + provenance (+ checks) | at least one snapshot and one anchor; evidence without a snapshot is invalid |
CheckResult |
one deterministic check outcome (pass/fail/warn/skipped) with a stable code |
code:"not_found" MUST be skipped |
Claim |
an assertion, its evidence bindings, its checks, its verdict | a verdict requires ≥1 check; verified requires ≥1 evidence, ≥1 passing verifying check and no failing check |
Artifact |
code / env / data / seed / command / figure / table | sha256:<hex> content hash |
AuditEvent |
append-only, hash-chained event | hash = sha256(canonicalJson(event minus hash)); prevHash links the chain |
ReportManifest |
the sealed report summary | integrity.manifestHash = sha256(canonicalJson(manifest minus integrity)) |
| Verdict | Means | Does not mean |
|---|---|---|
verified |
the checkable literals (quotes/numbers/metadata) were found and every bound snapshot re-hashes | the claim is true in a semantic sense |
unverified |
nothing was checked (typically: no evidence bound) | false |
insufficient |
the available evidence cannot decide it (e.g. a number could be computed, not quoted) | false, and not "clean" |
contradicted |
a bound snapshot failed its integrity check, or a numeric bridge disagrees | — |
disproven |
the source text explicitly does not contain the asserted quote | — |
not_found is a check code, not a verdict. It means the source could not be located. It is not evidence of fabrication and not evidence of cleanliness. It is always recorded as skipped, and an evidence item whose only outcome is not_found stays unchecked — never ok.
All REP hashes are computed over canonical JSON: object keys sorted by UTF-16 code unit, ECMAScript number serialization, no insignificant whitespace, undefined properties omitted, non-finite numbers / bigints / cycles / lone surrogates rejected. This follows RFC 8785 (JCS) for well-formed values.
import {
buildManifest, sealManifest, validateRep, verifyManifestSeal,
snapshotIdOf, canonicalJson, toSarif, renderRecordMarkdown,
} from '@perrylink/dsh-research-core'
const snapshot = {
snapshotId: snapshotIdOf(bytes),
mediaType: 'text/plain' as const,
bytes: bytes.byteLength,
path: `objects/${snapshotIdOf(bytes).slice('sha256:'.length)}`,
capturedAt: '2026-01-15T10:00:00.000Z',
sourceRef: { kind: 'file' as const, id: 'paper.txt', retrievedAt: '2026-01-15T10:00:00.000Z' },
}
// …build evidence/claims, then:
const result = validateRep(record) // invariants, cross-refs, audit chain, seal
const sarif = toSarif(record, { version: '1.0.0' })
const markdown = renderRecordMarkdown(record)
// inside a research plugin that optionally injects researchEvidence
const service = ctx.get('researchEvidence') as ResearchEvidenceService | undefined
if (service !== undefined) {
const { snapshot } = await service.capture({
bytes: pdfBytes, mediaType: 'application/pdf',
sourceRef: { kind: 'file', id: 'paper.pdf', retrievedAt: new Date().toISOString() },
})
await service.addEvidence({ sourceRef, snapshotIds: [snapshot.snapshotId], anchors, provenance })
await service.addClaim({ text, type: 'result', evidenceRefs: [evidenceId], locator })
const claim = await service.verifyClaim(claimId) // records the verdict
const sealed = await service.seal({ title, topic, generator })
await service.verifyRecord(sealed.record) // independent re-check
}
dsh-rep-verify <record.rep.json> [--objects <dir>] [--json] [--sarif]
record rec-fixture-sealed
manifest 9425dcf5… (sha256)
seal recomputed OK
snapshots 1 ok · 0 missing · 0 tampered
quotes 1/1 re-located verbatim
issues 0 error(s) · 0 warning(s)
RESULT verified
Exit codes: 0 verified · 1 verification failed · 2 usage/IO error.
Without --objects the record's invariants and seal are still checked, but snapshot hashes are reported as not_checked — the CLI never pretends it verified bytes it did not read.
This package registers no model-facing tools by design (the 18 plugins own the tools). Its surfaces are:
| Surface | Name | Notes |
|---|---|---|
| Service | ctx.researchEvidence |
16 methods: capture, addEvidence, setEvidenceChecks, addClaim, setVerdict, verifyClaim, getSnapshot, getEvidence, getClaim, listSnapshots, listEvidence, listClaims, summarize, buildRecord, seal, verifyRecord, plus attachReport / importReportEvidence / mirrorToReport |
| CLI | dsh-rep-verify |
exit-code driven, --json / --sarif |
| Schema | ./schema/rep-v1.schema.json |
JSON Schema 2020-12, $id published |
| Events | RESEARCH_EVENTS |
research/evidence.captured, research/claim.verified, research/audit.finding, research/report.sealed (names + payload types; emitting is the producing plugin's job) |
| Key | Default | Meaning |
|---|---|---|
enabled |
true |
false mounts nothing at all |
root |
.research-rep |
store root, resolved against the harness working directory |
maxSnapshotBytes |
20971520 (20 MiB) |
per-snapshot byte cap |
maxEvidence |
10000 |
evidence registrations before sealing/pruning |
maxClaims |
10000 |
claim registrations |
Invalid values fail loud at mount.
.research-rep/
├── objects/<sha256> immutable snapshot bytes (atomic write, never overwritten)
├── snapshots.jsonl snapshot registrations (first registration wins per address)
├── evidence.jsonl evidence registrations
├── evidence-checks.jsonl evidence checks (latest line wins)
├── claims.jsonl claim registrations (immutable)
├── verdicts.jsonl verdicts + their checks (latest line wins)
├── audits.jsonl append-only hash-chained audit events
└── records/<id>.rep.json sealed REP records
Every journal is append-only. A corrupt journal line fails loud with file and line number instead of being skipped. Reads re-hash snapshot objects, so tampering is detected, not trusted.
path must be objects/<hex> — path traversal cannot be expressed in a valid record.O_EXCL-style temp + rename and are never overwritten: if the stored bytes no longer hash to their address, the store refuses (SNAPSHOT_TAMPERED) instead of "repairing" it.RECORD_EXISTS).--force.dsh-doc-anchor to also capture the extracted text as a text/plain snapshot.verifyRecord/dsh-rep-verify re-locate quotes on Evidence.anchors; a claim-level locator.quote is evaluated by evaluateClaim/verifyClaim because a disproven claim intentionally carries a quote that must be absent.verifyClaim is conservative. A missing number yields insufficient (it might be computed), not disproven; only an absent verbatim quote is disproven. Semantic support is dsh-claim-check's job (W2).validateRep checks cross-references and invariants (and a defensive structural pre-pass); the JSON Schema is the authority on shape. The zero-dependency store enforces cross-references and invariants, not every JSON-Schema constraint (for example length bounds), so untrusted producers should validate against schema/rep-v1.schema.json at their boundary. CI checks both against the 20 golden fixtures.There are no precision/recall numbers for this package and it does not claim any: it is protocol infrastructure, not a detector. What is measured:
pnpm test), covering: canonical JSON determinism, SHA-256 vectors, claim evaluation (5 verdict paths), invariant validation, audit-chain tampering, manifest sealing, store durability, tamper detection, Cordis mount/dispose, the research-report bridge, and the CLI exit codes.test/fixtures/*.rep.json), 3 valid + 17 single-cause invalid, regenerated deterministically by the real functions and gated for drift (UPDATE_FIXTURES=1 pnpm test).either and covered by validateRep.Behavioral detectors (dsh-cite-verify, dsh-claim-check, dsh-statcheck) carry their own precision/recall numbers against dsh-research-bench.
pnpm install
pnpm run typecheck # sources + tests (TypeScript strict, exactOptionalPropertyTypes)
pnpm test # vitest
pnpm run build # tsc → lib/
pnpm run verify:package
UPDATE_FIXTURES=1 pnpm test # regenerate golden fixtures after an intentional change
Apache-2.0. No third-party runtime code; dev dependencies are MIT/Apache-2.0 tooling.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: research。