clearai-dsh 0.5.6 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/fold.js CHANGED
@@ -79,7 +79,7 @@ export const MUTATION_KIND = 'clearai'
79
79
  * v20 → v21:持久核算复核、最终实际引用、幂等审计派发;旧日志原样重放。
80
80
  * 投影缓存按版本判定,所以旧缓存会被丢弃、从日志重折一遍。
81
81
  */
82
- export const STATE_VERSION = 22
82
+ export const STATE_VERSION = 23
83
83
 
84
84
  /**
85
85
  * **只留台账、不折进视图**的变更类型(词汇表的另一半)。
@@ -597,7 +597,7 @@ export function applyMutation(state, mutation) {
597
597
  verdict: null,
598
598
  evaluator: 'independent',
599
599
  child: mutation.evaluator_session ?? null,
600
- capability: mutation.capability ?? null,
600
+ criteria: mutation.criteria ?? [], capability: mutation.capability ?? null,
601
601
  goal_id: mutation.goal_id ?? null,
602
602
  goal_revision: mutation.goal_revision ?? null,
603
603
  /**
@@ -653,7 +653,9 @@ export function applyMutation(state, mutation) {
653
653
  audit.rechecks = Array.isArray(mutation.rechecks) ? clone(mutation.rechecks) : []
654
654
  audit.lessons = Array.isArray(mutation.lessons) ? clone(mutation.lessons) : []
655
655
  audit.reuse = Array.isArray(mutation.reuse) ? clone(mutation.reuse) : []
656
- audit.results = Array.isArray(mutation.results) ? mutation.results : []
656
+ audit.refs = Array.isArray(mutation.refs) ? clone(mutation.refs) : []
657
+ audit.criteriaResults = Array.isArray(mutation.criteria) ? clone(mutation.criteria) : []
658
+ audit.results = Array.isArray(mutation.results) ? mutation.results : []
657
659
  audit.shortfalls = mutation.shortfalls ?? []
658
660
  audit.basis = mutation.basis ?? null
659
661
  audit.card_path = mutation.card_path ?? null
@@ -758,9 +760,15 @@ export function applyMutation(state, mutation) {
758
760
  * 每条 change 是一个文件的新样子(`data` 或读不成时的 `error`),或 `removed`。
759
761
  * 按路径覆盖,所以同一批变化折两遍结果一样。
760
762
  */
761
- case 'workspace/synced': {
763
+ case 'integrity/recorded': {
764
+ next.integrityReceipts = { ...(next.integrityReceipts ?? {}), [mutation.receipt.path]: mutation.receipt }; break
765
+ }
766
+ case 'audit/copy': {
767
+ next.auditCopies = { ...(next.auditCopies ?? {}), [mutation.id]: { ...(next.auditCopies?.[mutation.id] ?? {}), ...mutation } }; break
768
+ }
769
+ case 'workspace/synced': {
762
770
  const files = next.workspace !== null && typeof next.workspace === 'object' && next.workspace.files !== null && typeof next.workspace.files === 'object' ? next.workspace.files : {}
763
- next.workspace = { ...(next.workspace ?? {}), files }
771
+ next.workspace = { ...(next.workspace ?? {}), files, integrity: mutation.integrity ?? next.workspace?.integrity ?? [] }
764
772
  for (const change of Array.isArray(mutation.changes) ? mutation.changes : []) {
765
773
  const path = typeof change?.path === 'string' ? change.path : ''
766
774
  if (path === '') continue
@@ -1403,6 +1411,7 @@ function normalizeSelection(selection) {
1403
1411
  if (id === '') return null
1404
1412
  /** 调用方声明的类型优先认;声明了就必须对得上,不许「说 A 给 B」。 */
1405
1413
  const declared = typeof raw.kind === 'string' ? raw.kind : ''
1414
+ if (declared === 'edge') return { kind: 'edge', id }
1406
1415
  const ok = (kind) => declared === '' || declared === kind
1407
1416
  if (id.startsWith('term:')) return ok('concept') ? { kind: 'concept', id: id.slice('term:'.length) } : null
1408
1417
  if (id.startsWith('is_a:')) return ok('concept') ? { kind: 'concept', id: id.slice('is_a:'.length) } : null
@@ -1658,6 +1667,10 @@ function inspectPredicate(context, predicateId) {
1658
1667
  }
1659
1668
 
1660
1669
  /** 实例节点:某个具体对象身上挂着的全部断言与它们的链。 */
1670
+ function assertionSources(assertions) {
1671
+ return [...new Set(assertions.map(item => item.evidence?.ref).filter(Boolean))].join(' · ') || null
1672
+ }
1673
+
1661
1674
  function inspectInstance(context, key) {
1662
1675
  const { lexicon, facts, conflicts } = context
1663
1676
  const separator = key.indexOf('|')
@@ -1667,6 +1680,10 @@ function inspectInstance(context, key) {
1667
1680
  if (ref === '') return null
1668
1681
  const outgoing = []
1669
1682
  const incoming = []
1683
+ const registered = (context.state.entities ?? []).find(item => item.type === type && item.id === ref)
1684
+ const asserted = (context.state.entityAssertions ?? []).filter(item =>
1685
+ (item.subject?.type === type && item.subject?.id === ref) ||
1686
+ (item.object?.kind === 'instance' && item.object?.value === ref && (!item.object?.type || item.object.type === type)))
1670
1687
  for (const fact of facts) {
1671
1688
  for (const assertion of Array.isArray(fact.assertions) ? fact.assertions : []) {
1672
1689
  const subjectMatches = String(assertion?.subject?.type ?? '') === type && String(assertion?.subject?.id ?? '') === ref
@@ -1675,7 +1692,7 @@ function inspectInstance(context, key) {
1675
1692
  if (objectMatches) incoming.push({ fact, assertion, direction: 'in' })
1676
1693
  }
1677
1694
  }
1678
- if (outgoing.length === 0 && incoming.length === 0 && !lexicon.terms.some((item) => item.id === type)) return null
1695
+ if (outgoing.length === 0 && incoming.length === 0 && !registered && asserted.length === 0) return null
1679
1696
  const touchedFacts = [...new Set([...outgoing, ...incoming].map((item) => item.fact))]
1680
1697
  const chain = cut(touchedFacts)
1681
1698
  const edges = [...outgoing, ...incoming].map((item) => ({
@@ -1687,6 +1704,7 @@ function inspectInstance(context, key) {
1687
1704
  level: item.fact.level ?? null,
1688
1705
  status: item.fact.review?.decision === 'retracted' ? 'retracted' : item.fact.refuted === true ? 'refuted' : 'live',
1689
1706
  }))
1707
+ edges.push(...asserted.map(item => ({ direction: item.subject?.id === ref && item.subject?.type === type ? 'out' : 'in', predicate: item.predicate, chip: say(lexicon, item), fact: null, level: null, status: 'asserted' })))
1690
1708
  return {
1691
1709
  selection: { kind: 'instance', id: key, label: ref },
1692
1710
  definition: {
@@ -1695,7 +1713,8 @@ function inspectInstance(context, key) {
1695
1713
  type: type === '' ? null : type,
1696
1714
  typeLabel: type === '' ? null : lexicon.terms.find((item) => item.id === type)?.label ?? type,
1697
1715
  /** 实例**不注册**(从断言投影出来),所以它没有独立生命周期与版本史。 */
1698
- status: 'projected',
1716
+ status: touchedFacts.length > 0 ? 'projected' : 'asserted',
1717
+ basis: [registered?.basis, assertionSources(asserted)].filter(Boolean).join(' · ') || null,
1699
1718
  },
1700
1719
  relations: { edges, out: outgoing.length, in: incoming.length },
1701
1720
  facts: chain.rows.map((fact) => factChain(context, fact)),
@@ -1724,9 +1743,12 @@ function inspectLiteral(context, key) {
1724
1743
  holders.push({ fact, assertion })
1725
1744
  }
1726
1745
  }
1746
+ for (const assertion of context.state.entityAssertions ?? []) {
1747
+ if (String(assertion.predicate ?? '') === predicateId && objectKey(assertion.object) === objectPart) holders.push({ fact: null, assertion })
1748
+ }
1727
1749
  if (holders.length === 0) return null
1728
1750
  const predicate = lexicon.predicates.find((item) => item.id === predicateId) ?? null
1729
- const touchedFacts = [...new Set(holders.map((item) => item.fact))]
1751
+ const touchedFacts = [...new Set(holders.map((item) => item.fact).filter(Boolean))]
1730
1752
  const chain = cut(touchedFacts)
1731
1753
  return {
1732
1754
  selection: { kind: 'literal', id: key, label: say(lexicon, holders[0].assertion) },
@@ -1738,7 +1760,8 @@ function inspectLiteral(context, key) {
1738
1760
  value: holders[0].assertion?.object?.value ?? null,
1739
1761
  unit: holders[0].assertion?.object?.unit ?? null,
1740
1762
  /** 值形态决定「这个取值是什么东西」:数值 / 公式 / 代码路径 / 引用。 */
1741
- status: 'projected',
1763
+ status: touchedFacts.length > 0 ? 'projected' : 'asserted',
1764
+ basis: assertionSources(holders.filter(item => item.fact === null).map(item => item.assertion)),
1742
1765
  },
1743
1766
  relations: { holders: holders.length, predicateRange: predicate?.range ?? null },
1744
1767
  facts: chain.rows.map((fact) => factChain(context, fact)),
@@ -1753,12 +1776,32 @@ function inspectLiteral(context, key) {
1753
1776
  /** 断言边:一条事实边的完整链(图上点击一条边时看的就是它)。 */
1754
1777
  function inspectEdge(context, edgeId) {
1755
1778
  const { lexicon, facts, conflicts } = context
1756
- const parts = edgeId.split(':')
1757
- if (parts[0] !== 'assertion' || parts.length < 4) return null
1758
- const factId = parts[1]
1759
- const predicateId = parts[2]
1760
- /** 主语键里有 `|`,而它自己可能带 `:`——所以从第 4 段起重新拼回去(不按段数硬切)。 */
1761
- const subjectKey = parts.slice(3).join(':')
1779
+ const graph = graphProjection(context.state)
1780
+ const projected = graph.edges.find(edge => edge.id === edgeId)
1781
+ if (!projected) return null
1782
+ if (projected.layer === 'ontology' || projected.kind === 'part_of') {
1783
+ const label = id => graph.nodes.find(node => node.id === id)?.label ?? id
1784
+ return {
1785
+ selection: { kind: 'edge', id: edgeId, label: projected.label },
1786
+ definition: { kind: projected.kind, status: 'definition', gloss: `${label(projected.from)} → ${projected.label} → ${label(projected.to)}` },
1787
+ relations: {}, facts: [], factsTruncated: 0, conflicts: [], history: [],
1788
+ actions: { canFilter: true, canExpand: true, canEdit: false },
1789
+ }
1790
+ }
1791
+ if (projected.source === 'asserted') {
1792
+ const assertion = (context.state.entityAssertions ?? []).find(item => String(item.id ?? '') === projected.assertion)
1793
+ if (!assertion) return null
1794
+ return {
1795
+ selection: { kind: 'edge', id: edgeId, label: projected.label },
1796
+ definition: { kind: 'assertion', status: 'asserted', predicate: assertion.predicate, gloss: say(lexicon, assertion), basis: assertionSources([assertion]) },
1797
+ relations: {}, facts: [], factsTruncated: 0, conflicts: [], history: [],
1798
+ actions: { canFilter: true, canExpand: true, canEdit: false },
1799
+ }
1800
+ }
1801
+ if (projected.kind !== 'assertion') return null
1802
+ const factId = projected.fact
1803
+ const predicateId = projected.predicate
1804
+ const subjectKey = projected.from
1762
1805
  const fact = facts.find((item) => String(item.id ?? '') === factId)
1763
1806
  if (fact === undefined) return null
1764
1807
  const predicate = lexicon.predicates.find((item) => item.id === predicateId) ?? null
@@ -2372,6 +2415,8 @@ export function view(state, sessionId) {
2372
2415
  sessionId: sid,
2373
2416
  /** 待处理:只陈述的几行(计划停下、结论矛盾);面板顶上与输入框旁读同一份。 */
2374
2417
  needYou: derived.needYou,
2418
+ integrity: state.workspace?.integrity ?? [],
2419
+ auditCopies: Object.values(state.auditCopies ?? {}),
2375
2420
  /**
2376
2421
  * 被闸门裁断过几次(`block/counted`):世界树的**分段通道**画的就是它——
2377
2422
  * 这一步磨了几轮、其中几次被驳回。事实在投影里,面板只负责画。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clearai-dsh",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "ClearAI: an ontology-first DSH agent preset — evidence-checked research that grows into a domain ontology.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "engines": {
39
39
  "node": ">=22",
40
- "dsh": ">=0.2.0-rc.2"
40
+ "dsh": ">=0.2.2-rc.1"
41
41
  },
42
42
  "dependencies": {
43
43
  "zod": "^4.6.1"
@@ -83,7 +83,8 @@
83
83
  "e2e:long": "node tools/e2e-parallel.mjs",
84
84
  "vendor": "node tools/build-vendor.mjs",
85
85
  "check:browser": "node tools/browser-graph-check.mjs",
86
- "shots": "node tools/graph-shots.mjs"
86
+ "shots": "node tools/graph-shots.mjs",
87
+ "check:panels": "node tools/browser-panels-check.mjs"
87
88
  },
88
89
  "devDependencies": {
89
90
  "@xyflow/react": "^12.11.6",
@@ -247,9 +247,6 @@
247
247
  - id: tool-subagent-control
248
248
  name: '@deepseek-ai/dsh-tool-subagent-control'
249
249
 
250
- - id: tool-subagent-list-agents
251
- name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
252
-
253
250
  # 执行者自选模型:重活可以换模型跑(modelSelectionSettings 出面板设置)。
254
251
  - id: tool-subagent
255
252
  name: '@deepseek-ai/dsh-tool-subagent'
@@ -264,9 +264,6 @@
264
264
  - id: tool-subagent-control
265
265
  name: '@deepseek-ai/dsh-tool-subagent-control'
266
266
 
267
- - id: tool-subagent-list-agents
268
- name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
269
-
270
267
  # 执行者自选模型:重活可以换模型跑(modelSelectionSettings 出面板设置)。
271
268
  - id: tool-subagent
272
269
  name: '@deepseek-ai/dsh-tool-subagent'
@@ -0,0 +1,31 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { workspacePath } from './workspace-path.js'
3
+ import { contentDigest, fileDigest } from './audit-material.js'
4
+
5
+ export const auditCriteria = value => String(value ?? '').split(/\r?\n/).map(row => row.trim()).filter(Boolean).map((text, index) => ({ id: `C${index + 1}`, text }))
6
+
7
+ // A resolvable citation binds bytes, not truth, source independence or causality.
8
+ export function validateAuditEvidence(cwd, verdict, criteria) {
9
+ if (verdict.holds !== 'yes' && !(verdict.results ?? []).some(row => row.verdict === 'support')) return verdict
10
+ const refs = [], errors = []
11
+ for (const ref of verdict.refs ?? []) {
12
+ try {
13
+ const path = workspacePath(cwd, ref.path, { mustExist: true })
14
+ const bytes = readFileSync(path.absolute)
15
+ const lines = bytes.toString('utf8').split(/\r?\n/).length
16
+ if (!Number.isInteger(ref.line) || ref.line < 1 || ref.line > lines) throw new Error('invalid-line')
17
+ refs.push({ path: path.relative, line: ref.line, digest: contentDigest(bytes) })
18
+ } catch { errors.push(`audit_reference_invalid:${ref.path}`) }
19
+ }
20
+ if (!refs.length) errors.push('audit_references_required')
21
+ const rows = verdict.criteria ?? []
22
+ for (const criterion of criteria) {
23
+ const matches = rows.filter(row => row.criterion === criterion.id)
24
+ if (matches.length !== 1 || !['pass', 'fail', 'not_applicable'].includes(matches[0].result) || !matches[0].basis?.trim()) errors.push(`audit_criterion_missing:${criterion.id}`)
25
+ else if (verdict.holds === 'yes' && matches[0].result !== 'pass') errors.push(`audit_criterion_not_passed:${criterion.id}`)
26
+ }
27
+ if (!criteria.length || rows.some(row => !criteria.some(item => item.id === row.criterion))) errors.push('audit_criteria_invalid')
28
+ return errors.length ? { ...verdict, holds: 'unknown', results: [], shortfalls: [...(verdict.shortfalls ?? []), ...errors] } : { ...verdict, refs }
29
+ }
30
+
31
+ export const citationsUnchanged = (cwd, refs) => Array.isArray(refs) && refs.length > 0 && refs.every(ref => /^[a-f0-9]{64}$/.test(ref.digest ?? '') && fileDigest(cwd, ref.path) === ref.digest)
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import { readFileSync } from 'node:fs'
3
- import { isAbsolute, relative, resolve } from 'node:path'
3
+ import { resolve } from 'node:path'
4
+ import { workspacePath } from './workspace-path.js'
4
5
 
5
6
  // Both logical identifiers are opaque. No characters from either reach a path.
6
7
  export const auditPathComponent = (id) => createHash('sha256').update(String(id)).digest('hex')
@@ -12,26 +13,29 @@ export function canonical(value) {
12
13
  }
13
14
  export const contentDigest = (value) => createHash('sha256').update(typeof value === 'string' || Buffer.isBuffer(value) ? value : JSON.stringify(canonical(value))).digest('hex')
14
15
 
15
- // Missing/unreadable inputs are material too. Only workspace-relative references
16
- // are inspected; hashing must not create a new privilege or disclose file bytes.
16
+ // Error values are diagnostic only; auditMaterialDigest never caches them.
17
17
  export function fileDigest(cwd, path) {
18
- if (!cwd || typeof path !== 'string' || isAbsolute(path)) return 'unavailable'
19
- const file = resolve(cwd, path)
20
- const rel = relative(cwd, file)
21
- if (rel === '..' || rel.startsWith('../') || rel.startsWith('..\\')) return 'outside-workspace'
22
- try { return contentDigest(readFileSync(file)) } catch { return 'missing-or-unreadable' }
18
+ try { return contentDigest(readFileSync(workspacePath(cwd, path, { mustExist: true }).absolute)) }
19
+ catch (error) { return error.code === 'outside-workspace' ? 'outside-workspace' : 'missing-or-unreadable' }
23
20
  }
24
21
 
25
- export function methodSnapshot(cwd, spec, registration) {
22
+ export function methodSnapshot(cwd, spec, registration, digest = fileDigest) {
26
23
  const scripts = new Set(spec?.scripts ?? [])
27
24
  // Declared scripts are preferred; ordinary command file operands also count.
28
25
  for (const word of String(spec?.command ?? '').match(/[^\s"'`;|&<>]+/g) ?? []) {
29
26
  if (/\.(?:[cm]?js|py|sh|r|R)$/.test(word)) scripts.add(word)
30
27
  }
31
- return contentDigest({ registration: fileDigest(cwd, registration), command: spec?.command, scripts: [...scripts].sort().map((path) => [path, fileDigest(cwd, path)]) })
28
+ return contentDigest({ registration: digest(cwd, registration), command: spec?.command, scripts: [...scripts].sort().map((path) => [path, digest(cwd, path)]) })
32
29
  }
33
30
 
34
- export function auditMaterialDigest({ kind, step, plan, state, gate, cwd }) {
31
+ export function auditMaterialDigest({ kind, step, plan, state, gate, cwd, errors = [] }) {
32
+ const digest = (root, path) => {
33
+ const value = fileDigest(root, path)
34
+ if (!/^[a-f0-9]{64}$/.test(value)) errors.push({ path, code: value })
35
+ return value
36
+ }
37
+ const canonicalPath = path => { try { return workspacePath(cwd, path).relative } catch { return path } }
38
+
35
39
  const currentPlan = (state.plans ?? []).find((row) => row.id === plan?.id) ?? plan
36
40
  const modelIds = new Set((state.hypotheses ?? []).map((row) => row.use).filter(Boolean))
37
41
  const refs = new Set((state.hypotheses ?? []).flatMap((row) => (row.uses ?? []).map((use) => typeof use === 'string' ? use : use.id)))
@@ -39,21 +43,33 @@ export function auditMaterialDigest({ kind, step, plan, state, gate, cwd }) {
39
43
  const files = state.workspace?.files ?? {}
40
44
  const knowledge = Object.entries(files).filter(([, file]) => refs.has(file?.data?.id)).map(([path, file]) => {
41
45
  if (file?.data?.use) modelIds.add(file.data.use)
42
- return [path, fileDigest(cwd, path)]
46
+ return [path, digest(cwd, path)]
43
47
  })
44
- const paths = new Set((currentPlan?.steps ?? []).flatMap((row) => row.artifacts ?? []))
48
+ const paths = new Set(step.artifacts ?? [])
45
49
  for (const row of gate.confirmed ?? []) if (!/^(?:evidence|hypothesis):/.test(row.ref)) paths.add(row.ref)
46
- for (const row of state.materials ?? []) for (const path of [row.path, row.ref, ...(row.refs ?? [])]) if (typeof path === 'string' && !path.includes(':')) paths.add(path)
50
+ for (const row of state.materials ?? []) for (const path of [row.path, row.ref, ...(row.refs ?? [])]) if (typeof path === 'string' && !/^(?:evidence|hypothesis):/.test(path)) paths.add(path)
47
51
  const methods = [...modelIds].sort().map((id) => {
48
52
  const path = `clear/models/${id}.json`
49
53
  let spec = null
50
54
  try { spec = JSON.parse(readFileSync(resolve(cwd, path), 'utf8')) } catch {}
51
- return [id, methodSnapshot(cwd, spec, path), (spec?.inputs ?? []).map((input) => [input, fileDigest(cwd, input)]), spec?.output ? fileDigest(cwd, spec.output) : null]
55
+ return [id, methodSnapshot(cwd, spec, path, digest), (spec?.inputs ?? []).map((input) => [input, digest(cwd, input)]), spec?.output ? digest(cwd, spec.output) : null]
52
56
  })
53
57
  const semantic = (entry) => Object.fromEntries(['id', 'gloss', 'parent', 'kind', 'unit', 'domain', 'range', 'functional', 'shape', 'check', 'type', 'relations', 'status', 'replaced_by'].filter((key) => entry[key] !== undefined).map((key) => [key, entry[key]]))
54
58
  const lexicon = state.lexicon ?? {}
55
59
  const definitions = ['terms', 'predicates', 'entities'].flatMap((key) => (lexicon[key] ?? []).map(semantic))
56
60
  const anomalies = [...(state.anomalies ?? []), ...(gate.anomalies ?? [])].filter((row) => row.by !== 'evaluator' || row.status !== 'open').map((row) => ({ id: row.id, what: row.what, status: row.status, reason: row.reason, explainedBy: row.explainedBy }))
57
61
  const materials = [...new Set((state.materials ?? []).map(({ id, at, ...row }) => JSON.stringify(canonical(row))))].sort().map((row) => JSON.parse(row))
58
- return `v5:${contentDigest({ kind, step: step.id, criteria: step.done_criteria, goal: state.goal, steps: currentPlan?.steps, answers: gate.answers, lessons: gate.lessons, extra: gate.extra, hypotheses: (state.hypotheses ?? []).map(({ supportedLevel, refutations, inconclusive, ...row }) => row), facts: state.facts, evidence: (state.evidence ?? []).filter((row) => row.anchor !== 'auditor'), materials, anomalies, definitions, knowledge, methods, artifacts: [...paths].sort().map((path) => [path, fileDigest(cwd, path)]) })}`
62
+ const fingerprint = contentDigest({ kind, step: step.id, criteria: step.done_criteria, goal: state.goal, steps: currentPlan?.steps, answers: gate.answers, lessons: gate.lessons, extra: gate.extra, hypotheses: (state.hypotheses ?? []).map(({ supportedLevel, refutations, inconclusive, ...row }) => row), facts: state.facts, evidence: (state.evidence ?? []).filter((row) => row.anchor !== 'auditor'), materials, anomalies, definitions, knowledge, methods, artifacts: [...new Set([...paths].map(canonicalPath))].sort().map((path) => [path, digest(cwd, path)]) })
63
+ return errors.length ? null : `v6:${fingerprint}`
64
+ }
65
+
66
+ export function auditRerunInputs(cwd, state, step) {
67
+ const paths = new Set(step.artifacts ?? [])
68
+ for (const id of new Set((state.hypotheses ?? []).map(row => row.use).filter(Boolean))) {
69
+ const path = `clear/models/${id}.json`;paths.add(path)
70
+ const spec = JSON.parse(readFileSync(workspacePath(cwd,path,{mustExist:true}).absolute,'utf8'))
71
+ for (const value of [...(spec.inputs ?? []), ...(spec.scripts ?? []), spec.output].filter(Boolean)) paths.add(value)
72
+ for (const word of String(spec.command ?? '').match(/[^\s"'`;|&<>]+/g) ?? []) if (/\.(?:[cm]?js|py|sh|r|R)$/.test(word)) paths.add(word)
73
+ }
74
+ return [...paths]
59
75
  }