dsh-policy-ledger 0.2.0-alpha.10 → 0.2.0-alpha.11

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/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## [0.2.0-alpha.10] — 2026-11-01
3
+ ## [0.2.0-alpha.11] — 2026-11-01
4
+
5
+ ### Added
6
+
7
+ - `trust.risk_matrix`: fleet-level risk view over named snapshots — counts per R0-R3, the highest level and the R2/R3 names to review. Read-only. Verified by `node --test test/*.test.mjs` (10/10).
8
+
9
+ ## [Unreleased]
4
10
 
5
11
  ### Added
6
12
 
@@ -64,3 +64,15 @@ export interface Diagnosis {
64
64
  evidence_lines: string[];
65
65
  }
66
66
  export declare function classifyInstallLog(logText: string): Diagnosis;
67
+ export interface RiskRow {
68
+ name: string;
69
+ risk: Risk;
70
+ }
71
+ export interface RiskMatrix {
72
+ total: number;
73
+ by_risk: Record<Risk, number>;
74
+ highest: Risk | null;
75
+ attention: string[];
76
+ }
77
+ /** Fleet-level view of declared risks: counts by level, the highest level and the R2/R3 rows. */
78
+ export declare function riskMatrix(rows: RiskRow[]): RiskMatrix;
package/lib/core/trust.js CHANGED
@@ -107,3 +107,17 @@ export function classifyInstallLog(logText) {
107
107
  evidence_lines: lines.slice(0, 2),
108
108
  };
109
109
  }
110
+ /** Fleet-level view of declared risks: counts by level, the highest level and the R2/R3 rows. */
111
+ export function riskMatrix(rows) {
112
+ const by_risk = { R0: 0, R1: 0, R2: 0, R3: 0 };
113
+ let highest = null;
114
+ const attention = [];
115
+ for (const row of rows) {
116
+ by_risk[row.risk] += 1;
117
+ if (highest === null || RISK_ORDER[row.risk] > RISK_ORDER[highest])
118
+ highest = row.risk;
119
+ if (row.risk === 'R2' || row.risk === 'R3')
120
+ attention.push(row.name);
121
+ }
122
+ return { total: rows.length, by_risk, highest, attention: attention.sort() };
123
+ }
@@ -3,7 +3,7 @@ import { access, readFile, realpath, stat, statfs } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { defineTool } from '@deepseek-ai/dsh-tools';
5
5
  import { zipSync } from 'fflate';
6
- import { TrustError, canonicalJson, classifyInstallLog, diffSnapshots, riskBreakdown } from '../core/trust.js';
6
+ import { TrustError, canonicalJson, classifyInstallLog, diffSnapshots, riskBreakdown, riskMatrix } from '../core/trust.js';
7
7
  import { inspectPackageTarball } from '../adapters/tarball.js';
8
8
  import { newId, sha256Buffer, writeBundle, } from './storage.js';
9
9
  function text(value) {
@@ -323,5 +323,12 @@ export function createTools(deps) {
323
323
  output: { schema: { type: 'object', additionalProperties: false, properties: { risk: { type: 'string', required: true }, score: { type: 'number', required: true }, capped: { type: 'boolean', required: true }, factors: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: { factor: { type: 'string', required: true }, points: { type: 'number', required: true } } } } } }, render: (_a, v) => text(`risk ${v.risk} score ${v.score}`) },
324
324
  async execute(args) { return riskBreakdown(args.caps, args.hosts ?? [], args.build_scripts ?? [], args.cred_refs ?? []); },
325
325
  });
326
- return [snapshot, diff, assert, legacyAssert, diagnose, probe, bundle, riskReport];
326
+ const riskMatrixTool = defineTool({
327
+ name: 'trust.risk_matrix',
328
+ description: 'Fleet-level risk view over named snapshots: counts per R0-R3, the highest level and the R2/R3 names to review. Read-only.',
329
+ parameters: { rows: { type: 'array', required: true, items: { type: 'object', additionalProperties: false, properties: { name: { type: 'string', required: true }, risk: { type: 'string', required: true } } } } },
330
+ output: { schema: { type: 'object', additionalProperties: false, properties: { total: { type: 'number', required: true }, highest: { type: 'string' }, attention: { type: 'array', required: true, items: { type: 'string' } }, by_risk: { type: 'json', required: true } } }, render: (_a, v) => text(`risk matrix ${v.total} rows, highest ${v.highest ?? 'n/a'}`) },
331
+ async execute(args) { const m = riskMatrix(args.rows); return { total: m.total, highest: m.highest ?? undefined, attention: m.attention, by_risk: m.by_risk }; },
332
+ });
333
+ return [snapshot, diff, assert, legacyAssert, diagnose, probe, bundle, riskReport, riskMatrixTool];
327
334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-policy-ledger",
3
- "version": "0.2.0-alpha.10",
3
+ "version": "0.2.0-alpha.11",
4
4
  "description": "Read-only install doctor: capability snapshot, tarball assert and install diagnosis.",
5
5
  "type": "module",
6
6
  "main": "./lib/plugin/index.js",
package/screenshots.json CHANGED
@@ -16,5 +16,11 @@
16
16
  "kind": "capability",
17
17
  "alt": "dsh-policy-ledger real test run",
18
18
  "caption": "Real command: node --test test/risk-report.test.mjs — 4 tests passed, 0 failed (capability risk breakdown). Run 2026-11-01; the image is rendered from the captured terminal output."
19
+ },
20
+ {
21
+ "path": "docs/assets/dsh-policy-ledger-capability2.png",
22
+ "kind": "capability",
23
+ "alt": "dsh-policy-ledger second capability run",
24
+ "caption": "Real command: node --test test/risk-matrix.test.mjs — 3 tests passed, 0 failed (Fleet risk matrix: counts per level, highest level, review list.) Run 2026-11-01; rendered from the captured terminal output."
19
25
  }
20
26
  ]