@codeledger/engine 0.7.2 → 0.7.5
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/dist/broker/completion.d.ts +9 -0
- package/dist/broker/completion.d.ts.map +1 -0
- package/dist/broker/completion.js +51 -0
- package/dist/broker/completion.js.map +1 -0
- package/dist/broker/evidence.d.ts +11 -0
- package/dist/broker/evidence.d.ts.map +1 -0
- package/dist/broker/evidence.js +39 -0
- package/dist/broker/evidence.js.map +1 -0
- package/dist/broker/index.d.ts +14 -0
- package/dist/broker/index.d.ts.map +1 -0
- package/dist/broker/index.js +14 -0
- package/dist/broker/index.js.map +1 -0
- package/dist/broker/memory-lookup.d.ts +41 -0
- package/dist/broker/memory-lookup.d.ts.map +1 -0
- package/dist/broker/memory-lookup.js +70 -0
- package/dist/broker/memory-lookup.js.map +1 -0
- package/dist/broker/preamble.d.ts +19 -0
- package/dist/broker/preamble.d.ts.map +1 -0
- package/dist/broker/preamble.js +13 -0
- package/dist/broker/preamble.js.map +1 -0
- package/dist/broker/structural.d.ts +10 -0
- package/dist/broker/structural.d.ts.map +1 -0
- package/dist/broker/structural.js +52 -0
- package/dist/broker/structural.js.map +1 -0
- package/dist/broker/task-resolution.d.ts +17 -0
- package/dist/broker/task-resolution.d.ts.map +1 -0
- package/dist/broker/task-resolution.js +386 -0
- package/dist/broker/task-resolution.js.map +1 -0
- package/dist/broker/validation.d.ts +14 -0
- package/dist/broker/validation.d.ts.map +1 -0
- package/dist/broker/validation.js +75 -0
- package/dist/broker/validation.js.map +1 -0
- package/dist/claims/claims.d.ts +14 -0
- package/dist/claims/claims.d.ts.map +1 -0
- package/dist/claims/claims.js +125 -0
- package/dist/claims/claims.js.map +1 -0
- package/dist/claims/index.d.ts +2 -0
- package/dist/claims/index.d.ts.map +1 -0
- package/dist/claims/index.js +2 -0
- package/dist/claims/index.js.map +1 -0
- package/dist/dashboard/index.d.ts +3 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +3 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/metrics.d.ts +24 -0
- package/dist/dashboard/metrics.d.ts.map +1 -0
- package/dist/dashboard/metrics.js +358 -0
- package/dist/dashboard/metrics.js.map +1 -0
- package/dist/dashboard/store.d.ts +26 -0
- package/dist/dashboard/store.d.ts.map +1 -0
- package/dist/dashboard/store.js +97 -0
- package/dist/dashboard/store.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/insight/collector.d.ts +31 -0
- package/dist/insight/collector.d.ts.map +1 -0
- package/dist/insight/collector.js +172 -0
- package/dist/insight/collector.js.map +1 -0
- package/dist/insight/engine.d.ts +18 -0
- package/dist/insight/engine.d.ts.map +1 -0
- package/dist/insight/engine.js +84 -0
- package/dist/insight/engine.js.map +1 -0
- package/dist/insight/formatter.d.ts +9 -0
- package/dist/insight/formatter.d.ts.map +1 -0
- package/dist/insight/formatter.js +87 -0
- package/dist/insight/formatter.js.map +1 -0
- package/dist/insight/index.d.ts +13 -0
- package/dist/insight/index.d.ts.map +1 -0
- package/dist/insight/index.js +11 -0
- package/dist/insight/index.js.map +1 -0
- package/dist/insight/session.d.ts +11 -0
- package/dist/insight/session.d.ts.map +1 -0
- package/dist/insight/session.js +60 -0
- package/dist/insight/session.js.map +1 -0
- package/dist/integration/ambient-coordinator.d.ts +75 -0
- package/dist/integration/ambient-coordinator.d.ts.map +1 -0
- package/dist/integration/ambient-coordinator.js +183 -0
- package/dist/integration/ambient-coordinator.js.map +1 -0
- package/dist/integration/index.d.ts +4 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +3 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/warning-throttle.d.ts +63 -0
- package/dist/integration/warning-throttle.d.ts.map +1 -0
- package/dist/integration/warning-throttle.js +347 -0
- package/dist/integration/warning-throttle.js.map +1 -0
- package/dist/intervention/escalation.d.ts +23 -0
- package/dist/intervention/escalation.d.ts.map +1 -0
- package/dist/intervention/escalation.js +149 -0
- package/dist/intervention/escalation.js.map +1 -0
- package/dist/intervention/generator.d.ts +12 -0
- package/dist/intervention/generator.d.ts.map +1 -0
- package/dist/intervention/generator.js +191 -0
- package/dist/intervention/generator.js.map +1 -0
- package/dist/intervention/index.d.ts +4 -0
- package/dist/intervention/index.d.ts.map +1 -0
- package/dist/intervention/index.js +4 -0
- package/dist/intervention/index.js.map +1 -0
- package/dist/intervention/signal-aggregator.d.ts +26 -0
- package/dist/intervention/signal-aggregator.d.ts.map +1 -0
- package/dist/intervention/signal-aggregator.js +274 -0
- package/dist/intervention/signal-aggregator.js.map +1 -0
- package/dist/layer-d/conflict-detector.d.ts +12 -0
- package/dist/layer-d/conflict-detector.d.ts.map +1 -0
- package/dist/layer-d/conflict-detector.js +150 -0
- package/dist/layer-d/conflict-detector.js.map +1 -0
- package/dist/layer-d/index.d.ts +3 -0
- package/dist/layer-d/index.d.ts.map +1 -0
- package/dist/layer-d/index.js +3 -0
- package/dist/layer-d/index.js.map +1 -0
- package/dist/layer-d/surface-extractor.d.ts +10 -0
- package/dist/layer-d/surface-extractor.d.ts.map +1 -0
- package/dist/layer-d/surface-extractor.js +96 -0
- package/dist/layer-d/surface-extractor.js.map +1 -0
- package/dist/policy-domains/domains.d.ts +31 -0
- package/dist/policy-domains/domains.d.ts.map +1 -0
- package/dist/policy-domains/domains.js +445 -0
- package/dist/policy-domains/domains.js.map +1 -0
- package/dist/policy-domains/index.d.ts +8 -0
- package/dist/policy-domains/index.d.ts.map +1 -0
- package/dist/policy-domains/index.js +8 -0
- package/dist/policy-domains/index.js.map +1 -0
- package/dist/pulse/index.d.ts +2 -0
- package/dist/pulse/index.d.ts.map +1 -0
- package/dist/pulse/index.js +2 -0
- package/dist/pulse/index.js.map +1 -0
- package/dist/pulse/pulse.d.ts +20 -0
- package/dist/pulse/pulse.d.ts.map +1 -0
- package/dist/pulse/pulse.js +253 -0
- package/dist/pulse/pulse.js.map +1 -0
- package/dist/severity/index.d.ts +2 -0
- package/dist/severity/index.d.ts.map +1 -0
- package/dist/severity/index.js +2 -0
- package/dist/severity/index.js.map +1 -0
- package/dist/severity/severity.d.ts +48 -0
- package/dist/severity/severity.d.ts.map +1 -0
- package/dist/severity/severity.js +134 -0
- package/dist/severity/severity.js.map +1 -0
- package/dist/staleness/index.d.ts +2 -0
- package/dist/staleness/index.d.ts.map +1 -0
- package/dist/staleness/index.js +2 -0
- package/dist/staleness/index.js.map +1 -0
- package/dist/staleness/jit-staleness.d.ts +29 -0
- package/dist/staleness/jit-staleness.d.ts.map +1 -0
- package/dist/staleness/jit-staleness.js +240 -0
- package/dist/staleness/jit-staleness.js.map +1 -0
- package/dist/team-policy/index.d.ts +1 -1
- package/dist/team-policy/index.d.ts.map +1 -1
- package/dist/team-policy/index.js +1 -1
- package/dist/team-policy/index.js.map +1 -1
- package/dist/team-policy/policy.d.ts +7 -0
- package/dist/team-policy/policy.d.ts.map +1 -1
- package/dist/team-policy/policy.js +38 -0
- package/dist/team-policy/policy.js.map +1 -1
- package/dist/trust/approval.d.ts +16 -0
- package/dist/trust/approval.d.ts.map +1 -0
- package/dist/trust/approval.js +183 -0
- package/dist/trust/approval.js.map +1 -0
- package/dist/trust/capsule.d.ts +36 -0
- package/dist/trust/capsule.d.ts.map +1 -0
- package/dist/trust/capsule.js +206 -0
- package/dist/trust/capsule.js.map +1 -0
- package/dist/trust/index.d.ts +6 -0
- package/dist/trust/index.d.ts.map +1 -0
- package/dist/trust/index.js +6 -0
- package/dist/trust/index.js.map +1 -0
- package/dist/trust/learning-feedback.d.ts +18 -0
- package/dist/trust/learning-feedback.d.ts.map +1 -0
- package/dist/trust/learning-feedback.js +146 -0
- package/dist/trust/learning-feedback.js.map +1 -0
- package/dist/trust/risk-scoring.d.ts +16 -0
- package/dist/trust/risk-scoring.d.ts.map +1 -0
- package/dist/trust/risk-scoring.js +142 -0
- package/dist/trust/risk-scoring.js.map +1 -0
- package/dist/trust/timeline.d.ts +42 -0
- package/dist/trust/timeline.d.ts.map +1 -0
- package/dist/trust/timeline.js +154 -0
- package/dist/trust/timeline.js.map +1 -0
- package/package.json +10 -2
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard Data Store — Append-only JSONL persistence for dashboard snapshots
|
|
3
|
+
*
|
|
4
|
+
* Storage: .codeledger/dashboard-history.jsonl
|
|
5
|
+
*
|
|
6
|
+
* Each line is a JSON-encoded DashboardSnapshot.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync, appendFileSync, existsSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
export const DASHBOARD_HISTORY_FILE = 'dashboard-history.jsonl';
|
|
11
|
+
// Trend threshold: delta > 0.02 = improving, delta < -0.02 = degrading
|
|
12
|
+
const TREND_THRESHOLD = 0.02;
|
|
13
|
+
// ─── Public API ──────────────────────────────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* Append a dashboard metrics snapshot to the JSONL history file.
|
|
16
|
+
*/
|
|
17
|
+
export function appendDashboardSnapshot(dataDir, metrics, source = 'cli') {
|
|
18
|
+
const snapshot = {
|
|
19
|
+
...metrics,
|
|
20
|
+
snapshot_source: source,
|
|
21
|
+
};
|
|
22
|
+
const filePath = join(dataDir, DASHBOARD_HISTORY_FILE);
|
|
23
|
+
const line = JSON.stringify(snapshot) + '\n';
|
|
24
|
+
appendFileSync(filePath, line, 'utf-8');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read all dashboard snapshots from the JSONL history file.
|
|
28
|
+
* Returns an empty array if the file does not exist.
|
|
29
|
+
*/
|
|
30
|
+
export function readDashboardHistory(dataDir) {
|
|
31
|
+
const filePath = join(dataDir, DASHBOARD_HISTORY_FILE);
|
|
32
|
+
if (!existsSync(filePath))
|
|
33
|
+
return [];
|
|
34
|
+
try {
|
|
35
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
36
|
+
const lines = content.split('\n').filter((l) => l.trim().length > 0);
|
|
37
|
+
const snapshots = [];
|
|
38
|
+
for (const line of lines) {
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(line);
|
|
41
|
+
snapshots.push(parsed);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Skip malformed lines
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return snapshots;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Compute trend directions from dashboard history.
|
|
55
|
+
*
|
|
56
|
+
* Uses the last 5 entries to determine if each metric is improving, stable, or degrading.
|
|
57
|
+
* For DRI and override_frequency, a decrease is "improving" (lower risk is better).
|
|
58
|
+
*/
|
|
59
|
+
export function computeTrends(history) {
|
|
60
|
+
if (history.length < 2) {
|
|
61
|
+
return {
|
|
62
|
+
ahs_trend: 'stable',
|
|
63
|
+
dri_trend: 'stable',
|
|
64
|
+
eds_trend: 'stable',
|
|
65
|
+
sts_trend: 'stable',
|
|
66
|
+
override_trend: 'stable',
|
|
67
|
+
overall_trend: 'stable',
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Use last 5 entries (or fewer)
|
|
71
|
+
const recent = history.slice(-5);
|
|
72
|
+
const first = recent[0];
|
|
73
|
+
const last = recent[recent.length - 1];
|
|
74
|
+
return {
|
|
75
|
+
ahs_trend: trendDirection(last.ahs - first.ahs, false),
|
|
76
|
+
dri_trend: trendDirection(last.dri - first.dri, true), // inverted: decrease = improving
|
|
77
|
+
eds_trend: trendDirection(last.eds - first.eds, false),
|
|
78
|
+
sts_trend: trendDirection(last.sts - first.sts, false),
|
|
79
|
+
override_trend: trendDirection(last.override_frequency - first.override_frequency, true), // inverted
|
|
80
|
+
overall_trend: trendDirection(last.overall - first.overall, false),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Determine trend direction from a delta value.
|
|
85
|
+
*
|
|
86
|
+
* @param delta - The difference (last - first)
|
|
87
|
+
* @param inverted - If true, a negative delta is "improving" (e.g., DRI, overrides)
|
|
88
|
+
*/
|
|
89
|
+
function trendDirection(delta, inverted) {
|
|
90
|
+
const effectiveDelta = inverted ? -delta : delta;
|
|
91
|
+
if (effectiveDelta > TREND_THRESHOLD)
|
|
92
|
+
return 'improving';
|
|
93
|
+
if (effectiveDelta < -TREND_THRESHOLD)
|
|
94
|
+
return 'degrading';
|
|
95
|
+
return 'stable';
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/dashboard/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAEhE,uEAAuE;AACvE,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAe,EACf,OAAyB,EACzB,SAAiB,KAAK;IAEtB,MAAM,QAAQ,GAAsB;QAClC,GAAG,OAAO;QACV,eAAe,EAAE,MAAM;KACxB,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAC7C,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,QAAQ,GAA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C,MAAM,GAAG,CAAC,CAAE,CAAC;IAExC,OAAO;QACL,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC;QACtD,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,iCAAiC;QACxF,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC;QACtD,SAAS,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC;QACtD,cAAc,EAAE,cAAc,CAAC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,EAAE,WAAW;QACrG,aAAa,EAAE,cAAc,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;KACnE,CAAC;AACJ,CAAC;AAMD;;;;;GAKG;AACH,SAAS,cAAc,CAAC,KAAa,EAAE,QAAiB;IACtD,MAAM,cAAc,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAEjD,IAAI,cAAc,GAAG,eAAe;QAAE,OAAO,WAAW,CAAC;IACzD,IAAI,cAAc,GAAG,CAAC,eAAe;QAAE,OAAO,WAAW,CAAC;IAC1D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -51,4 +51,16 @@ export * from './team-metrics/index.js';
|
|
|
51
51
|
export * from './provenance/index.js';
|
|
52
52
|
export * from './policy-sim/index.js';
|
|
53
53
|
export * from './orchestrator/index.js';
|
|
54
|
+
export * from './pulse/index.js';
|
|
55
|
+
export * from './layer-d/index.js';
|
|
56
|
+
export * from './severity/index.js';
|
|
57
|
+
export * from './claims/index.js';
|
|
58
|
+
export * from './staleness/index.js';
|
|
59
|
+
export * from './integration/index.js';
|
|
60
|
+
export * from './trust/index.js';
|
|
61
|
+
export * from './dashboard/index.js';
|
|
62
|
+
export * from './intervention/index.js';
|
|
63
|
+
export * from './policy-domains/index.js';
|
|
64
|
+
export * from './broker/index.js';
|
|
65
|
+
export * from './insight/index.js';
|
|
54
66
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,oBAAoB,CAAC;AAGnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -53,4 +53,27 @@ export * from './team-metrics/index.js';
|
|
|
53
53
|
export * from './provenance/index.js';
|
|
54
54
|
export * from './policy-sim/index.js';
|
|
55
55
|
export * from './orchestrator/index.js';
|
|
56
|
+
// v2.5 — Pulse: Ambient Session Discovery
|
|
57
|
+
export * from './pulse/index.js';
|
|
58
|
+
// Layer D — Semantic / Signature Conflict Detection
|
|
59
|
+
export * from './layer-d/index.js';
|
|
60
|
+
// v2.6 — Conflict Severity Matrix & Soft Claims
|
|
61
|
+
export * from './severity/index.js';
|
|
62
|
+
export * from './claims/index.js';
|
|
63
|
+
// v2.7 — JIT Staleness / Context Shadowing
|
|
64
|
+
export * from './staleness/index.js';
|
|
65
|
+
// v2.8 — Ambient Coordination Integration Layer
|
|
66
|
+
export * from './integration/index.js';
|
|
67
|
+
// v3.0 — Executive Trust: Command Capsules & Approval Workflow
|
|
68
|
+
export * from './trust/index.js';
|
|
69
|
+
// v3.1 — Architecture Health Dashboard
|
|
70
|
+
export * from './dashboard/index.js';
|
|
71
|
+
// v3.2 — Architecture Intervention Engine
|
|
72
|
+
export * from './intervention/index.js';
|
|
73
|
+
// v3.3 — Policy Domain Framework (Governance-as-Code)
|
|
74
|
+
export * from './policy-domains/index.js';
|
|
75
|
+
// v3.4 — Context Broker (system-awareness layer for non-terminal agents)
|
|
76
|
+
export * from './broker/index.js';
|
|
77
|
+
// v3.5 — Insight System (value dashboard)
|
|
78
|
+
export * from './insight/index.js';
|
|
56
79
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,wDAAwD;AACxD,cAAc,oBAAoB,CAAC;AAEnC,yCAAyC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B,wDAAwD;AACxD,cAAc,oBAAoB,CAAC;AAEnC,yCAAyC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAExC,0CAA0C;AAC1C,cAAc,kBAAkB,CAAC;AAEjC,oDAAoD;AACpD,cAAc,oBAAoB,CAAC;AAEnC,gDAAgD;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAElC,2CAA2C;AAC3C,cAAc,sBAAsB,CAAC;AAErC,gDAAgD;AAChD,cAAc,wBAAwB,CAAC;AAEvC,+DAA+D;AAC/D,cAAc,kBAAkB,CAAC;AAEjC,uCAAuC;AACvC,cAAc,sBAAsB,CAAC;AAErC,0CAA0C;AAC1C,cAAc,yBAAyB,CAAC;AAExC,sDAAsD;AACtD,cAAc,2BAA2B,CAAC;AAE1C,yEAAyE;AACzE,cAAc,mBAAmB,CAAC;AAElC,0CAA0C;AAC1C,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight Collector — ingests guardrail events, CIC transitions,
|
|
3
|
+
* validation ledger data, and pre-PR/release-check results.
|
|
4
|
+
*
|
|
5
|
+
* Every collected item MUST have a verifiable provenance (ID or ledger entry).
|
|
6
|
+
* No narrative hallucination — if it can't be traced, it's not collected.
|
|
7
|
+
*/
|
|
8
|
+
import type { GuardrailResult, CompletionRecord, CompletionState, ReleaseCheckResult, ReleaseState, PrePRReport, InsightPreventedIssue, InsightWorkAvoided, InsightTruthEstablished, InsightStateTransition } from '@codeledger/types';
|
|
9
|
+
/** Raw inputs the collector accepts */
|
|
10
|
+
export interface CollectorInput {
|
|
11
|
+
guardrails?: GuardrailResult[];
|
|
12
|
+
completionRecord?: CompletionRecord;
|
|
13
|
+
previousCompletionState?: CompletionState;
|
|
14
|
+
releaseResult?: ReleaseCheckResult;
|
|
15
|
+
previousReleaseState?: ReleaseState;
|
|
16
|
+
prePRReport?: PrePRReport;
|
|
17
|
+
validationSurfaces?: number;
|
|
18
|
+
reusedSurfaces?: number;
|
|
19
|
+
totalRepoFiles?: number;
|
|
20
|
+
scannedFiles?: number;
|
|
21
|
+
skippedTests?: number;
|
|
22
|
+
}
|
|
23
|
+
/** Collected insight data ready for the engine */
|
|
24
|
+
export interface CollectedInsight {
|
|
25
|
+
prevented: InsightPreventedIssue[];
|
|
26
|
+
workAvoided: InsightWorkAvoided;
|
|
27
|
+
truth: InsightTruthEstablished;
|
|
28
|
+
transitions: InsightStateTransition[];
|
|
29
|
+
}
|
|
30
|
+
export declare function collect(input: CollectorInput): CollectedInsight;
|
|
31
|
+
//# sourceMappingURL=collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/insight/collector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,WAAW,EAEX,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,uCAAuC;AACvC,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uBAAuB,CAAC,EAAE,eAAe,CAAC;IAC1C,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,oBAAoB,CAAC,EAAE,YAAY,CAAC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,qBAAqB,EAAE,CAAC;IACnC,WAAW,EAAE,kBAAkB,CAAC;IAChC,KAAK,EAAE,uBAAuB,CAAC;IAC/B,WAAW,EAAE,sBAAsB,EAAE,CAAC;CACvC;AA0BD,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB,CA4J/D"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight Collector — ingests guardrail events, CIC transitions,
|
|
3
|
+
* validation ledger data, and pre-PR/release-check results.
|
|
4
|
+
*
|
|
5
|
+
* Every collected item MUST have a verifiable provenance (ID or ledger entry).
|
|
6
|
+
* No narrative hallucination — if it can't be traced, it's not collected.
|
|
7
|
+
*/
|
|
8
|
+
const COMPLETION_ORDER = [
|
|
9
|
+
'incomplete', 'edited', 'implemented', 'wired', 'verified', 'audited', 'release_safe',
|
|
10
|
+
];
|
|
11
|
+
const RELEASE_ORDER = [
|
|
12
|
+
'not_ready', 'ready_conditional', 'ready', 'ready_hardened',
|
|
13
|
+
];
|
|
14
|
+
const COMPLETION_DELTAS = {
|
|
15
|
+
'verified': 15,
|
|
16
|
+
'audited': 20,
|
|
17
|
+
'release_safe': 25,
|
|
18
|
+
};
|
|
19
|
+
const RELEASE_DELTAS = {
|
|
20
|
+
'ready_conditional': 5,
|
|
21
|
+
'ready': 10,
|
|
22
|
+
'ready_hardened': 25,
|
|
23
|
+
};
|
|
24
|
+
function isPromotion(order, from, to) {
|
|
25
|
+
return order.indexOf(to) > order.indexOf(from);
|
|
26
|
+
}
|
|
27
|
+
export function collect(input) {
|
|
28
|
+
const prevented = [];
|
|
29
|
+
const transitions = [];
|
|
30
|
+
const truth = {};
|
|
31
|
+
// ── Guardrail events → prevented issues ────────────────────────────────
|
|
32
|
+
if (input.guardrails) {
|
|
33
|
+
for (const g of input.guardrails) {
|
|
34
|
+
if (g.outcome === 'fail' || g.outcome === 'warn') {
|
|
35
|
+
prevented.push({
|
|
36
|
+
id: g.id,
|
|
37
|
+
description: g.detail,
|
|
38
|
+
severity: g.outcome === 'fail' ? 'high' : 'medium',
|
|
39
|
+
source: 'guardrail',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// ── Pre-PR findings → prevented issues (severity >= medium) ────────────
|
|
45
|
+
if (input.prePRReport) {
|
|
46
|
+
const allFindings = [
|
|
47
|
+
...input.prePRReport.blockers,
|
|
48
|
+
...input.prePRReport.warnings,
|
|
49
|
+
];
|
|
50
|
+
for (const f of allFindings) {
|
|
51
|
+
if (f.severity === 'critical' || f.severity === 'high' || f.severity === 'medium') {
|
|
52
|
+
prevented.push({
|
|
53
|
+
id: `pre-pr:${f.category}:${f.title.slice(0, 40).replace(/\s+/g, '_')}`,
|
|
54
|
+
description: f.title,
|
|
55
|
+
severity: f.severity === 'critical' ? 'critical' : f.severity === 'high' ? 'high' : 'medium',
|
|
56
|
+
source: 'pre_pr',
|
|
57
|
+
recursiveImpact: f.files && f.files.length > 2
|
|
58
|
+
? `affects ${f.files.length} files — potential cascade`
|
|
59
|
+
: undefined,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// ── Release findings → prevented issues ────────────────────────────────
|
|
65
|
+
if (input.releaseResult) {
|
|
66
|
+
for (const f of input.releaseResult.findings) {
|
|
67
|
+
if (f.severity === 'critical' || f.severity === 'high' || f.severity === 'medium') {
|
|
68
|
+
prevented.push({
|
|
69
|
+
id: f.id,
|
|
70
|
+
description: f.title,
|
|
71
|
+
severity: f.severity === 'critical' ? 'critical' : f.severity === 'high' ? 'high' : 'medium',
|
|
72
|
+
source: 'release_check',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// ── CIC drift/mismatch warnings → prevented issues ────────────────────
|
|
78
|
+
if (input.completionRecord) {
|
|
79
|
+
const rec = input.completionRecord;
|
|
80
|
+
if (rec.semanticDriftWarnings) {
|
|
81
|
+
for (const d of rec.semanticDriftWarnings) {
|
|
82
|
+
prevented.push({
|
|
83
|
+
id: `cic:drift:${d.term.replace(/\s+/g, '_')}`,
|
|
84
|
+
description: `Semantic drift: "${d.term}" expected ${d.expectedConcept} — ${d.detail}`,
|
|
85
|
+
severity: 'medium',
|
|
86
|
+
source: 'cic',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (rec.realityMismatches) {
|
|
91
|
+
for (const m of rec.realityMismatches) {
|
|
92
|
+
if (!m.actualDiffPresence) {
|
|
93
|
+
prevented.push({
|
|
94
|
+
id: `cic:mismatch:${m.expectedTarget.replace(/\//g, '_')}`,
|
|
95
|
+
description: `Reality mismatch: claim "${m.claim}" — ${m.expectedTarget} not in diff`,
|
|
96
|
+
severity: m.severity === 'critical' ? 'critical' : m.severity === 'major' ? 'high' : 'medium',
|
|
97
|
+
source: 'cic',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (rec.guards) {
|
|
103
|
+
for (const g of rec.guards) {
|
|
104
|
+
if (g.outcome === 'fail') {
|
|
105
|
+
prevented.push({
|
|
106
|
+
id: g.id,
|
|
107
|
+
description: g.detail,
|
|
108
|
+
severity: 'high',
|
|
109
|
+
source: 'guardrail',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// ── CIC state transitions → truth + transitions ───────────────────────
|
|
116
|
+
if (input.completionRecord) {
|
|
117
|
+
truth.completionState = input.completionRecord.completionState;
|
|
118
|
+
if (input.previousCompletionState) {
|
|
119
|
+
const from = input.previousCompletionState;
|
|
120
|
+
const to = input.completionRecord.completionState;
|
|
121
|
+
if (isPromotion(COMPLETION_ORDER, from, to)) {
|
|
122
|
+
transitions.push({
|
|
123
|
+
from,
|
|
124
|
+
to,
|
|
125
|
+
label: `completion: ${from} → ${to}`,
|
|
126
|
+
delta: COMPLETION_DELTAS[to] ?? 10,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// ── Release state transitions → truth + transitions ───────────────────
|
|
132
|
+
if (input.releaseResult) {
|
|
133
|
+
truth.releaseState = input.releaseResult.releaseState;
|
|
134
|
+
if (input.previousReleaseState) {
|
|
135
|
+
const from = input.previousReleaseState;
|
|
136
|
+
const to = input.releaseResult.releaseState;
|
|
137
|
+
if (isPromotion(RELEASE_ORDER, from, to)) {
|
|
138
|
+
transitions.push({
|
|
139
|
+
from,
|
|
140
|
+
to,
|
|
141
|
+
label: `release: ${from} → ${to}`,
|
|
142
|
+
delta: RELEASE_DELTAS[to] ?? 5,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// ── Pre-PR pass → confidence transition ───────────────────────────────
|
|
148
|
+
if (input.prePRReport && input.prePRReport.verdict === 'PASS') {
|
|
149
|
+
transitions.push({
|
|
150
|
+
from: 'unchecked',
|
|
151
|
+
to: 'pre_pr_pass',
|
|
152
|
+
label: 'pre-pr: passed all checks',
|
|
153
|
+
delta: 10,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// ── Work avoided ──────────────────────────────────────────────────────
|
|
157
|
+
const reusedSurfaces = input.reusedSurfaces ?? 0;
|
|
158
|
+
const contextScansAvoided = input.totalRepoFiles && input.scannedFiles
|
|
159
|
+
? input.totalRepoFiles - input.scannedFiles
|
|
160
|
+
: 0;
|
|
161
|
+
const skippedTests = input.skippedTests ?? 0;
|
|
162
|
+
// Estimate: ~2s per surface revalidation, ~2s per file scan, ~1s per test
|
|
163
|
+
const estimatedTimeSavedSec = (reusedSurfaces * 2) + (contextScansAvoided > 0 ? Math.round(contextScansAvoided * 2) : 0) + (skippedTests * 1);
|
|
164
|
+
const workAvoided = {
|
|
165
|
+
surfaces: reusedSurfaces,
|
|
166
|
+
tests: skippedTests,
|
|
167
|
+
contextScansAvoided,
|
|
168
|
+
estimatedTimeSavedSec: estimatedTimeSavedSec > 0 ? estimatedTimeSavedSec : undefined,
|
|
169
|
+
};
|
|
170
|
+
return { prevented, workAvoided, truth, transitions };
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/insight/collector.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuCH,MAAM,gBAA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AAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IAElH,MAAM,WAAW,GAAuB;QACtC,QAAQ,EAAE,cAAc;QACxB,KAAK,EAAE,YAAY;QACnB,mBAAmB;QACnB,qBAAqB,EAAE,qBAAqB,GAAG,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS;KACrF,CAAC;IAEF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight Engine — computes value signals from collected data.
|
|
3
|
+
*
|
|
4
|
+
* Applies value detection rules:
|
|
5
|
+
* - Prevented: only severity >= medium
|
|
6
|
+
* - Avoided: >3 surfaces OR >10 files OR >30s estimated
|
|
7
|
+
* - Confidence: delta >= 10
|
|
8
|
+
*
|
|
9
|
+
* Produces an InsightResult with silence/health-pulse flags.
|
|
10
|
+
*/
|
|
11
|
+
import type { InsightResult } from '@codeledger/types';
|
|
12
|
+
import type { CollectedInsight } from './collector.js';
|
|
13
|
+
export interface InsightEngineOptions {
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
consecutiveSilentCount?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function computeInsight(collected: CollectedInsight, opts?: InsightEngineOptions): InsightResult;
|
|
18
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/insight/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAWvD,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,gBAAgB,EAC3B,IAAI,GAAE,oBAAyB,GAC9B,aAAa,CAgDf"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight Engine — computes value signals from collected data.
|
|
3
|
+
*
|
|
4
|
+
* Applies value detection rules:
|
|
5
|
+
* - Prevented: only severity >= medium
|
|
6
|
+
* - Avoided: >3 surfaces OR >10 files OR >30s estimated
|
|
7
|
+
* - Confidence: delta >= 10
|
|
8
|
+
*
|
|
9
|
+
* Produces an InsightResult with silence/health-pulse flags.
|
|
10
|
+
*/
|
|
11
|
+
/** Thresholds for value detection (from spec §7) */
|
|
12
|
+
const THRESHOLDS = {
|
|
13
|
+
minSeverity: 'medium',
|
|
14
|
+
minSurfaces: 3,
|
|
15
|
+
minFiles: 10,
|
|
16
|
+
minTimeSavedSec: 30,
|
|
17
|
+
minConfidenceDelta: 10,
|
|
18
|
+
};
|
|
19
|
+
export function computeInsight(collected, opts = {}) {
|
|
20
|
+
// ── Confidence delta from state transitions ────────────────────────────
|
|
21
|
+
const confidenceDelta = collected.transitions.reduce((sum, t) => sum + t.delta, 0);
|
|
22
|
+
// ── Apply value detection rules ────────────────────────────────────────
|
|
23
|
+
// Prevented: already filtered to >= medium in collector
|
|
24
|
+
const preventedDetails = collected.prevented;
|
|
25
|
+
const preventedIssues = preventedDetails.length;
|
|
26
|
+
// Work avoided: check thresholds
|
|
27
|
+
const wa = collected.workAvoided;
|
|
28
|
+
const workIsSignificant = wa.surfaces > THRESHOLDS.minSurfaces ||
|
|
29
|
+
wa.contextScansAvoided > THRESHOLDS.minFiles ||
|
|
30
|
+
(wa.estimatedTimeSavedSec != null && wa.estimatedTimeSavedSec > THRESHOLDS.minTimeSavedSec);
|
|
31
|
+
// Zero out work avoided display if below thresholds
|
|
32
|
+
const workAvoided = workIsSignificant ? wa : {
|
|
33
|
+
surfaces: 0,
|
|
34
|
+
tests: 0,
|
|
35
|
+
contextScansAvoided: 0,
|
|
36
|
+
};
|
|
37
|
+
// Confidence: only show if >= threshold
|
|
38
|
+
const showConfidence = confidenceDelta >= THRESHOLDS.minConfidenceDelta;
|
|
39
|
+
// ── Silence rule (§3) ─────────────────────────────────────────────────
|
|
40
|
+
const silent = preventedIssues === 0 && !workIsSignificant && !showConfidence;
|
|
41
|
+
// ── Health pulse (§4) — triggers after 3+ consecutive silent outputs ──
|
|
42
|
+
const healthPulse = silent && (opts.consecutiveSilentCount ?? 0) >= 3;
|
|
43
|
+
// ── Next action (§8) — single, state-driven ───────────────────────────
|
|
44
|
+
const recommendedAction = deriveNextAction(collected);
|
|
45
|
+
return {
|
|
46
|
+
preventedIssues,
|
|
47
|
+
preventedDetails,
|
|
48
|
+
workAvoided,
|
|
49
|
+
truthEstablished: collected.truth,
|
|
50
|
+
confidenceDelta: showConfidence ? confidenceDelta : 0,
|
|
51
|
+
stateTransitions: collected.transitions,
|
|
52
|
+
recommendedAction,
|
|
53
|
+
silent,
|
|
54
|
+
healthPulse,
|
|
55
|
+
timestamp: new Date().toISOString(),
|
|
56
|
+
sessionId: opts.sessionId,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function deriveNextAction(collected) {
|
|
60
|
+
// Priority: critical preventions → state gaps → nothing
|
|
61
|
+
const criticals = collected.prevented.filter(p => p.severity === 'critical');
|
|
62
|
+
if (criticals.length > 0) {
|
|
63
|
+
return `fix ${criticals.length} critical issue${criticals.length > 1 ? 's' : ''} before proceeding`;
|
|
64
|
+
}
|
|
65
|
+
const highs = collected.prevented.filter(p => p.severity === 'high');
|
|
66
|
+
if (highs.length > 0) {
|
|
67
|
+
return `resolve ${highs.length} high-severity finding${highs.length > 1 ? 's' : ''}`;
|
|
68
|
+
}
|
|
69
|
+
// State-driven suggestions
|
|
70
|
+
if (collected.truth.completionState === 'implemented') {
|
|
71
|
+
return 'run complete-check to verify';
|
|
72
|
+
}
|
|
73
|
+
if (collected.truth.completionState === 'verified' && !collected.truth.releaseState) {
|
|
74
|
+
return 'run pre-pr before opening PR';
|
|
75
|
+
}
|
|
76
|
+
if (collected.truth.releaseState === 'ready_conditional') {
|
|
77
|
+
return 'resolve conditions for full release readiness';
|
|
78
|
+
}
|
|
79
|
+
if (collected.truth.releaseState === 'ready') {
|
|
80
|
+
return 'run release-check --strict for hardened release';
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/insight/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,oDAAoD;AACpD,MAAM,UAAU,GAAG;IACjB,WAAW,EAAE,QAAiB;IAC9B,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE,EAAE;IACZ,eAAe,EAAE,EAAE;IACnB,kBAAkB,EAAE,EAAE;CACvB,CAAC;AAOF,MAAM,UAAU,cAAc,CAC5B,SAA2B,EAC3B,OAA6B,EAAE;IAE/B,0EAA0E;IAC1E,MAAM,eAAe,GAAG,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAEnF,0EAA0E;IAC1E,wDAAwD;IACxD,MAAM,gBAAgB,GAAG,SAAS,CAAC,SAAS,CAAC;IAC7C,MAAM,eAAe,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAEhD,iCAAiC;IACjC,MAAM,EAAE,GAAG,SAAS,CAAC,WAAW,CAAC;IACjC,MAAM,iBAAiB,GACrB,EAAE,CAAC,QAAQ,GAAG,UAAU,CAAC,WAAW;QACpC,EAAE,CAAC,mBAAmB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,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,SAAS,CAAC,MAAM,kBAAkB,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC;IACtG,CAAC;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;IACrE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,WAAW,KAAK,CAAC,MAAM,yBAAyB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACvF,CAAC;IAED,2BAA2B;IAC3B,IAAI,SAAS,CAAC,KAAK,CAAC,eAAe,KAAK,aAAa,EAAE,CAAC;QACtD,OAAO,8BAA8B,CAAC;IACxC,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,eAAe,KAAK,UAAU,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;QACpF,OAAO,8BAA8B,CAAC;IACxC,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,YAAY,KAAK,mBAAmB,EAAE,CAAC;QACzD,OAAO,+CAA+C,CAAC;IACzD,CAAC;IACD,IAAI,SAAS,CAAC,KAAK,CAAC,YAAY,KAAK,OAAO,EAAE,CAAC;QAC7C,OAAO,iDAAiD,CAAC;IAC3D,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight Formatter — human (≤10 lines) and JSON output.
|
|
3
|
+
*/
|
|
4
|
+
import type { InsightResult } from '@codeledger/types';
|
|
5
|
+
/** Format InsightResult as human-readable output (≤10 lines per spec §5) */
|
|
6
|
+
export declare function formatInsightHuman(result: InsightResult): string[];
|
|
7
|
+
/** Format InsightResult as JSON string */
|
|
8
|
+
export declare function formatInsightJson(result: InsightResult): string;
|
|
9
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/insight/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAkFlE;AAED,0CAA0C;AAC1C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAE/D"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight Formatter — human (≤10 lines) and JSON output.
|
|
3
|
+
*/
|
|
4
|
+
/** Format InsightResult as human-readable output (≤10 lines per spec §5) */
|
|
5
|
+
export function formatInsightHuman(result) {
|
|
6
|
+
// ── Health pulse (§4) ─────────────────────────────────────────────────
|
|
7
|
+
if (result.healthPulse) {
|
|
8
|
+
return [
|
|
9
|
+
'',
|
|
10
|
+
'\u{1F9E0} CodeLedger Health',
|
|
11
|
+
'---------------------',
|
|
12
|
+
'\u2714 100% integrity maintained',
|
|
13
|
+
'\u2714 No intervention required',
|
|
14
|
+
'\u2714 System actively monitoring',
|
|
15
|
+
'',
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
// ── Silence rule (§3) ─────────────────────────────────────────────────
|
|
19
|
+
if (result.silent) {
|
|
20
|
+
return [
|
|
21
|
+
'',
|
|
22
|
+
'\u2714 No issues detected',
|
|
23
|
+
'\u2714 No unnecessary work',
|
|
24
|
+
'\u2714 System stable',
|
|
25
|
+
'',
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
// ── Full insight output (§5) ──────────────────────────────────────────
|
|
29
|
+
const lines = ['', '\u{1F9E0} CodeLedger Insight', '---------------------'];
|
|
30
|
+
// Prevented
|
|
31
|
+
if (result.preventedIssues > 0) {
|
|
32
|
+
const top = result.preventedDetails.slice(0, 3);
|
|
33
|
+
const summary = top.map(p => {
|
|
34
|
+
const base = p.description.length > 60
|
|
35
|
+
? p.description.slice(0, 57) + '...'
|
|
36
|
+
: p.description;
|
|
37
|
+
return p.recursiveImpact ? `${base} (${p.recursiveImpact})` : base;
|
|
38
|
+
}).join('; ');
|
|
39
|
+
const extra = result.preventedIssues > 3 ? ` (+${result.preventedIssues - 3} more)` : '';
|
|
40
|
+
lines.push(`\u2714 PREVENTED: ${summary}${extra}`);
|
|
41
|
+
}
|
|
42
|
+
// Avoided
|
|
43
|
+
const wa = result.workAvoided;
|
|
44
|
+
const avoidedParts = [];
|
|
45
|
+
if (wa.surfaces > 0)
|
|
46
|
+
avoidedParts.push(`${wa.surfaces} surfaces reused`);
|
|
47
|
+
if (wa.contextScansAvoided > 0)
|
|
48
|
+
avoidedParts.push(`${wa.contextScansAvoided} files skipped`);
|
|
49
|
+
if (wa.tests > 0)
|
|
50
|
+
avoidedParts.push(`${wa.tests} redundant tests skipped`);
|
|
51
|
+
if (wa.estimatedTimeSavedSec && wa.estimatedTimeSavedSec > 0) {
|
|
52
|
+
avoidedParts.push(`~${wa.estimatedTimeSavedSec}s saved`);
|
|
53
|
+
}
|
|
54
|
+
if (avoidedParts.length > 0) {
|
|
55
|
+
lines.push(`\u2714 AVOIDED: ${avoidedParts.join(', ')}`);
|
|
56
|
+
}
|
|
57
|
+
// Truth
|
|
58
|
+
const truthParts = [];
|
|
59
|
+
if (result.truthEstablished.completionState) {
|
|
60
|
+
truthParts.push(`completion ${result.truthEstablished.completionState}`);
|
|
61
|
+
}
|
|
62
|
+
if (result.truthEstablished.releaseState) {
|
|
63
|
+
truthParts.push(`release ${result.truthEstablished.releaseState}`);
|
|
64
|
+
}
|
|
65
|
+
if (truthParts.length > 0) {
|
|
66
|
+
lines.push(`\u2714 TRUTH: ${truthParts.join(', ')}`);
|
|
67
|
+
}
|
|
68
|
+
// Confidence
|
|
69
|
+
if (result.confidenceDelta > 0) {
|
|
70
|
+
const lastTransition = result.stateTransitions[result.stateTransitions.length - 1];
|
|
71
|
+
const label = lastTransition ? lastTransition.label : 'state promoted';
|
|
72
|
+
lines.push('');
|
|
73
|
+
lines.push(`Confidence: +${result.confidenceDelta}% (${label})`);
|
|
74
|
+
}
|
|
75
|
+
// Next action
|
|
76
|
+
if (result.recommendedAction) {
|
|
77
|
+
lines.push('');
|
|
78
|
+
lines.push(`\u{1F449} Next: ${result.recommendedAction}`);
|
|
79
|
+
}
|
|
80
|
+
lines.push('');
|
|
81
|
+
return lines;
|
|
82
|
+
}
|
|
83
|
+
/** Format InsightResult as JSON string */
|
|
84
|
+
export function formatInsightJson(result) {
|
|
85
|
+
return JSON.stringify(result, null, 2);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/insight/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB,CAAC,MAAqB;IACtD,yEAAyE;IACzE,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,OAAO;YACL,EAAE;YACF,6BAA6B;YAC7B,uBAAuB;YACvB,kCAAkC;YAClC,iCAAiC;YACjC,mCAAmC;YACnC,EAAE;SACH,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,OAAO;YACL,EAAE;YACF,2BAA2B;YAC3B,4BAA4B;YAC5B,sBAAsB;YACtB,EAAE;SACH,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,MAAM,KAAK,GAAa,CAAC,EAAE,EAAE,8BAA8B,EAAE,uBAAuB,CAAC,CAAC;IAEtF,YAAY;IACZ,IAAI,MAAM,CAA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AM,CAAC,eAAe,MAAM,KAAK,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,cAAc;IACd,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC;AACf,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,iBAAiB,CAAC,MAAqB;IACrD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight System — value dashboard for CodeLedger.
|
|
3
|
+
*
|
|
4
|
+
* Shows prevented risk, avoided work, truth progression,
|
|
5
|
+
* and confidence deltas after key commands.
|
|
6
|
+
*/
|
|
7
|
+
export { collect } from './collector.js';
|
|
8
|
+
export type { CollectorInput, CollectedInsight } from './collector.js';
|
|
9
|
+
export { computeInsight } from './engine.js';
|
|
10
|
+
export type { InsightEngineOptions } from './engine.js';
|
|
11
|
+
export { formatInsightHuman, formatInsightJson } from './formatter.js';
|
|
12
|
+
export { storeInsight, loadSessionInsights, getConsecutiveSilentCount, } from './session.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/insight/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Insight System — value dashboard for CodeLedger.
|
|
3
|
+
*
|
|
4
|
+
* Shows prevented risk, avoided work, truth progression,
|
|
5
|
+
* and confidence deltas after key commands.
|
|
6
|
+
*/
|
|
7
|
+
export { collect } from './collector.js';
|
|
8
|
+
export { computeInsight } from './engine.js';
|
|
9
|
+
export { formatInsightHuman, formatInsightJson } from './formatter.js';
|
|
10
|
+
export { storeInsight, loadSessionInsights, getConsecutiveSilentCount, } from './session.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/insight/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|