avorelo 0.1.0 → 0.3.0
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/LICENSE +23 -16
- package/README.md +90 -51
- package/bin/avorelo.mjs +7 -0
- package/dist/avorelo.mjs +19741 -0
- package/package.json +135 -120
- package/bin/avorelo +0 -9
- package/scripts/README.md +0 -40
- package/scripts/cco-dashboard.js +0 -252
- package/scripts/cco-status.js +0 -430
- package/scripts/lib/activation/account-state.js +0 -37
- package/scripts/lib/activation/activation-runner.js +0 -546
- package/scripts/lib/activation/activation-self-healing.js +0 -480
- package/scripts/lib/activation/activation-state.js +0 -83
- package/scripts/lib/activation/activation-summary.js +0 -191
- package/scripts/lib/activation/adapters/claude-code.js +0 -77
- package/scripts/lib/activation/adapters/codex-cli.js +0 -52
- package/scripts/lib/activation/adapters/cursor.js +0 -37
- package/scripts/lib/activation/adapters/github-agent.js +0 -39
- package/scripts/lib/activation/adapters/terminal.js +0 -42
- package/scripts/lib/activation/adapters/vscode.js +0 -39
- package/scripts/lib/activation/adapters/windsurf.js +0 -37
- package/scripts/lib/activation/ai-surface-detector.js +0 -151
- package/scripts/lib/activation/connect-account.js +0 -145
- package/scripts/lib/activation/detect-environment.js +0 -75
- package/scripts/lib/activation/detect-hosts.js +0 -62
- package/scripts/lib/activation/format-activation-output.js +0 -109
- package/scripts/lib/activation/next-action.js +0 -43
- package/scripts/lib/activation/repair-engine.js +0 -219
- package/scripts/lib/activation-distribution-readiness.js +0 -507
- package/scripts/lib/adapter-conformance.js +0 -176
- package/scripts/lib/adapter-readiness.js +0 -417
- package/scripts/lib/adapter-safety-boundaries.js +0 -335
- package/scripts/lib/adapter-technical-readiness-gate.js +0 -205
- package/scripts/lib/agent-access-governance.js +0 -455
- package/scripts/lib/agent-enforcement.js +0 -765
- package/scripts/lib/agent-policy-profile.js +0 -210
- package/scripts/lib/agent-security/action-evaluator.js +0 -507
- package/scripts/lib/agent-security/adapter-registry.js +0 -98
- package/scripts/lib/agent-security/auto-policy.js +0 -139
- package/scripts/lib/agent-security/bounded-scan.js +0 -93
- package/scripts/lib/agent-security/enforcement-adapter.js +0 -174
- package/scripts/lib/agent-security/enforcement-engine.js +0 -1129
- package/scripts/lib/agent-security/file-write-adapter.js +0 -183
- package/scripts/lib/agent-security/file-write-rules.js +0 -178
- package/scripts/lib/agent-security/index.js +0 -3342
- package/scripts/lib/agent-security/instruction-risk.js +0 -181
- package/scripts/lib/agent-security/mcp-action-adapter.js +0 -185
- package/scripts/lib/agent-security/mcp-action-rules.js +0 -184
- package/scripts/lib/agent-security/package-action-adapter.js +0 -175
- package/scripts/lib/agent-security/package-action-rules.js +0 -233
- package/scripts/lib/agent-security/performance.js +0 -148
- package/scripts/lib/agent-security/permission-minimizer.js +0 -403
- package/scripts/lib/agent-security/scan-cache.js +0 -74
- package/scripts/lib/agent-security/source-trust.js +0 -146
- package/scripts/lib/ai-install-prompt.js +0 -288
- package/scripts/lib/ai-workspace-hygiene.js +0 -1499
- package/scripts/lib/alpha-activation.js +0 -520
- package/scripts/lib/alpha-feedback.js +0 -263
- package/scripts/lib/alpha-readiness-gate.js +0 -332
- package/scripts/lib/anti-gaming.js +0 -169
- package/scripts/lib/artifact-health.js +0 -431
- package/scripts/lib/attribution.js +0 -180
- package/scripts/lib/audit.js +0 -289
- package/scripts/lib/avorelo-skill-registry.js +0 -810
- package/scripts/lib/batch-jobs.js +0 -71
- package/scripts/lib/brain-pack.js +0 -578
- package/scripts/lib/brand-boundary.js +0 -424
- package/scripts/lib/brand.js +0 -74
- package/scripts/lib/browser-capability.js +0 -1048
- package/scripts/lib/browser-proof-preflight.js +0 -321
- package/scripts/lib/cache-readiness.js +0 -187
- package/scripts/lib/canonical-reentry.js +0 -162
- package/scripts/lib/capability-packs.js +0 -314
- package/scripts/lib/capability-recommender.js +0 -512
- package/scripts/lib/capability-registry.js +0 -1059
- package/scripts/lib/carry-forward-surfacing.js +0 -194
- package/scripts/lib/ccusage-adapter.js +0 -188
- package/scripts/lib/company-loop.js +0 -1149
- package/scripts/lib/config.js +0 -637
- package/scripts/lib/context-acquisition-plan.js +0 -287
- package/scripts/lib/context-budget-guard.js +0 -170
- package/scripts/lib/context-budget-scanner.js +0 -257
- package/scripts/lib/context-optimizer.js +0 -715
- package/scripts/lib/context-reduction-plan.js +0 -178
- package/scripts/lib/context-safety.js +0 -88
- package/scripts/lib/context-savings-engine.js +0 -158
- package/scripts/lib/cost-evidence.js +0 -254
- package/scripts/lib/cross-host-install-plan.js +0 -308
- package/scripts/lib/cross-host-install-readiness.js +0 -237
- package/scripts/lib/cross-host-value-flow.js +0 -268
- package/scripts/lib/dashboard.js +0 -900
- package/scripts/lib/design-partner-feedback.js +0 -346
- package/scripts/lib/entitlements.js +0 -100
- package/scripts/lib/execution-packet.js +0 -559
- package/scripts/lib/experimentation-events.js +0 -547
- package/scripts/lib/external-capability-compliance.js +0 -107
- package/scripts/lib/external-user-simulation.js +0 -166
- package/scripts/lib/failure-recovery-readiness.js +0 -81
- package/scripts/lib/failure-recovery.js +0 -419
- package/scripts/lib/feedback-intelligence.js +0 -537
- package/scripts/lib/feedback-signals.js +0 -205
- package/scripts/lib/file-integrity.js +0 -68
- package/scripts/lib/fsx.js +0 -127
- package/scripts/lib/full-readiness-gate.js +0 -451
- package/scripts/lib/guidance-builder.js +0 -174
- package/scripts/lib/hook-apply.js +0 -1019
- package/scripts/lib/hook-baseline.js +0 -310
- package/scripts/lib/hook-config-preview.js +0 -275
- package/scripts/lib/hook-contracts.js +0 -290
- package/scripts/lib/hook-safety-boundary-readiness.js +0 -80
- package/scripts/lib/host-capability-matrix.js +0 -351
- package/scripts/lib/host-support-context.js +0 -254
- package/scripts/lib/http-hook-action.js +0 -538
- package/scripts/lib/install-ai-readiness.js +0 -84
- package/scripts/lib/install-intake-risk.js +0 -1037
- package/scripts/lib/install-journey-intelligence.js +0 -329
- package/scripts/lib/intervention-guidance.js +0 -57
- package/scripts/lib/known-limitations.js +0 -115
- package/scripts/lib/l8-path-truth.js +0 -146
- package/scripts/lib/launch-hardening-gate.js +0 -436
- package/scripts/lib/launch-readiness.js +0 -628
- package/scripts/lib/learning-memory.js +0 -686
- package/scripts/lib/lifecycle-hooks.js +0 -802
- package/scripts/lib/local-package-smoke.js +0 -423
- package/scripts/lib/local-pricing.js +0 -299
- package/scripts/lib/mcp-enforcement.js +0 -311
- package/scripts/lib/mcp-least-privilege-policy.js +0 -303
- package/scripts/lib/mcp-tool-inventory.js +0 -388
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +0 -335
- package/scripts/lib/metrics.js +0 -699
- package/scripts/lib/micro-proof.js +0 -133
- package/scripts/lib/next-run-context.js +0 -436
- package/scripts/lib/operating-value.js +0 -1648
- package/scripts/lib/optimization-v3.js +0 -122
- package/scripts/lib/orchestration/adapters/_shared.js +0 -49
- package/scripts/lib/orchestration/adapters/aider.js +0 -18
- package/scripts/lib/orchestration/adapters/claude-code.js +0 -35
- package/scripts/lib/orchestration/adapters/codex.js +0 -35
- package/scripts/lib/orchestration/adapters/gemini-cli.js +0 -18
- package/scripts/lib/orchestration/adapters/git.js +0 -25
- package/scripts/lib/orchestration/adapters/index.js +0 -31
- package/scripts/lib/orchestration/adapters/lm-studio.js +0 -18
- package/scripts/lib/orchestration/adapters/ollama.js +0 -18
- package/scripts/lib/orchestration/adapters/opencode.js +0 -18
- package/scripts/lib/orchestration/adapters/openrouter.js +0 -18
- package/scripts/lib/orchestration/adapters/test-runner.js +0 -25
- package/scripts/lib/orchestration/cli.js +0 -438
- package/scripts/lib/orchestration/execution-manager.js +0 -279
- package/scripts/lib/orchestration/handoff.js +0 -314
- package/scripts/lib/orchestration/index.js +0 -456
- package/scripts/lib/orchestration/inventory.js +0 -47
- package/scripts/lib/orchestration/model-discovery.js +0 -498
- package/scripts/lib/orchestration/model-profiler.js +0 -170
- package/scripts/lib/orchestration/model-profiles.js +0 -252
- package/scripts/lib/orchestration/model-refresh-policy.js +0 -72
- package/scripts/lib/orchestration/proof-writer.js +0 -349
- package/scripts/lib/orchestration/provider-discovery/aider.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +0 -56
- package/scripts/lib/orchestration/provider-discovery/codex.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/common.js +0 -186
- package/scripts/lib/orchestration/provider-discovery/gemini.js +0 -106
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +0 -118
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +0 -12
- package/scripts/lib/orchestration/provider-discovery/ollama.js +0 -100
- package/scripts/lib/orchestration/provider-discovery/opencode.js +0 -47
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +0 -44
- package/scripts/lib/orchestration/risk-classifier.js +0 -130
- package/scripts/lib/orchestration/routing-policy.js +0 -486
- package/scripts/lib/orchestration/settings.js +0 -112
- package/scripts/lib/orchestration/state.js +0 -165
- package/scripts/lib/orchestration/verification-manager.js +0 -138
- package/scripts/lib/output-profiles.js +0 -146
- package/scripts/lib/package-content-audit.js +0 -368
- package/scripts/lib/package-runtime.js +0 -278
- package/scripts/lib/plan-surface.js +0 -53
- package/scripts/lib/plans.js +0 -2318
- package/scripts/lib/policy-provider.js +0 -27
- package/scripts/lib/prelaunch-activation-readiness.js +0 -409
- package/scripts/lib/prelaunch-evidence-store.js +0 -816
- package/scripts/lib/prelaunch-intelligence.js +0 -869
- package/scripts/lib/pricing-experiment.js +0 -118
- package/scripts/lib/pro-moment-events.js +0 -77
- package/scripts/lib/pro-moment-state.js +0 -227
- package/scripts/lib/pro-moments.js +0 -1216
- package/scripts/lib/product-learning-events.js +0 -629
- package/scripts/lib/project-profile.js +0 -555
- package/scripts/lib/prompt-compiler.js +0 -280
- package/scripts/lib/prompt-lint.js +0 -32
- package/scripts/lib/prompt-suggestions.js +0 -52
- package/scripts/lib/proof-canonical.js +0 -398
- package/scripts/lib/proof-drilldown.js +0 -383
- package/scripts/lib/proof-events.js +0 -342
- package/scripts/lib/proof-history.js +0 -243
- package/scripts/lib/proof-metrics.js +0 -296
- package/scripts/lib/proof-outcome-evidence.js +0 -134
- package/scripts/lib/proof-receipt.js +0 -335
- package/scripts/lib/proof-record.js +0 -461
- package/scripts/lib/public-activation-distribution-gate.js +0 -258
- package/scripts/lib/public-cli.js +0 -3891
- package/scripts/lib/public-distribution-truth.js +0 -211
- package/scripts/lib/public-install-claim-checker.js +0 -294
- package/scripts/lib/publish-provenance-readiness.js +0 -283
- package/scripts/lib/readiness-delta.js +0 -218
- package/scripts/lib/readiness-evidence-closure.js +0 -196
- package/scripts/lib/reentry-memory-capture.js +0 -241
- package/scripts/lib/reentry-memory-retrieval.js +0 -302
- package/scripts/lib/reentry-memory-status.js +0 -146
- package/scripts/lib/reentry-memory-store.js +0 -178
- package/scripts/lib/reentry-state.js +0 -66
- package/scripts/lib/release-candidate-bundle.js +0 -166
- package/scripts/lib/remediation.js +0 -81
- package/scripts/lib/repo-map.js +0 -391
- package/scripts/lib/run-improvements-lifecycle.js +0 -330
- package/scripts/lib/run-improvements.js +0 -789
- package/scripts/lib/runtime-decision-policy.js +0 -387
- package/scripts/lib/safe-path-engine.js +0 -705
- package/scripts/lib/safe-run-controller.js +0 -887
- package/scripts/lib/score.js +0 -262
- package/scripts/lib/seamless-enforcement.js +0 -329
- package/scripts/lib/seamless-outcome.js +0 -689
- package/scripts/lib/seamless-reality-gate.js +0 -5043
- package/scripts/lib/security-risk-classifier.js +0 -511
- package/scripts/lib/security-scan.js +0 -384
- package/scripts/lib/session-context-optimizer.js +0 -1211
- package/scripts/lib/session-timing.js +0 -315
- package/scripts/lib/skill-hygiene.js +0 -805
- package/scripts/lib/skill-packs.js +0 -161
- package/scripts/lib/skills-operating-layer.js +0 -580
- package/scripts/lib/smart-work-routing.js +0 -768
- package/scripts/lib/source-catalog.js +0 -700
- package/scripts/lib/status-value-summary.js +0 -32
- package/scripts/lib/support-bundle.js +0 -578
- package/scripts/lib/task-continuation.js +0 -440
- package/scripts/lib/test-helpers.js +0 -15
- package/scripts/lib/tier.js +0 -38
- package/scripts/lib/token-context-quality-gate.js +0 -370
- package/scripts/lib/token-cost-capture.js +0 -187
- package/scripts/lib/token-cost-intelligence.js +0 -358
- package/scripts/lib/token-efficiency-evidence.js +0 -213
- package/scripts/lib/token-evidence.js +0 -699
- package/scripts/lib/tokenish.js +0 -17
- package/scripts/lib/tool-output-sandbox.js +0 -304
- package/scripts/lib/trust-audit.js +0 -136
- package/scripts/lib/unified-events.js +0 -396
- package/scripts/lib/upgrade-interruption-recovery.js +0 -407
- package/scripts/lib/usage-ledger.js +0 -201
- package/scripts/lib/value-ledger.js +0 -130
- package/scripts/lib/value-proof-calibration.js +0 -531
- package/scripts/lib/visual-qa.js +0 -231
- package/scripts/lib/voice-alpha.js +0 -29
- package/scripts/lib/work-aware-orchestration.js +0 -976
- package/scripts/lib/work-control-receipts.js +0 -577
- package/scripts/lib/work-ledger.js +0 -1123
- package/scripts/lib/work-panel-preview.js +0 -352
- package/scripts/lib/workflow-discipline.js +0 -280
- package/scripts/lib/workflow-signals.js +0 -419
- package/scripts/lib/workspace-map.js +0 -281
- package/scripts/lib/workspace-registry.js +0 -1367
- package/scripts/lib/workspace-resolver.js +0 -480
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
|
|
6
|
-
const LEDGER_REL = ".claude/cco/state/value-ledger.jsonl";
|
|
7
|
-
const SCHEMA_VERSION = 1;
|
|
8
|
-
const VALID_BUCKETS = new Set([
|
|
9
|
-
"context_avoided",
|
|
10
|
-
"large_output_referenced",
|
|
11
|
-
"reentry_reused",
|
|
12
|
-
"memory_recalled",
|
|
13
|
-
"proof_completed",
|
|
14
|
-
"proof_gap_avoided",
|
|
15
|
-
"risky_action_reduced",
|
|
16
|
-
"workflow_recommendation_used",
|
|
17
|
-
"external_context_provider_detected",
|
|
18
|
-
]);
|
|
19
|
-
const MAX_LABEL_LEN = 200;
|
|
20
|
-
const MAX_NOTES_LEN = 500;
|
|
21
|
-
const MAX_ARTIFACT_LEN = 300;
|
|
22
|
-
|
|
23
|
-
function buildEvent(partial) {
|
|
24
|
-
const bucket = partial.bucket;
|
|
25
|
-
if (!VALID_BUCKETS.has(bucket)) {
|
|
26
|
-
throw new Error(`Invalid bucket: ${bucket}`);
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
schemaVersion: SCHEMA_VERSION,
|
|
30
|
-
bucket,
|
|
31
|
-
ts: partial.ts || new Date().toISOString(),
|
|
32
|
-
sessionId: partial.sessionId || null,
|
|
33
|
-
label: String(partial.label || "").slice(0, MAX_LABEL_LEN),
|
|
34
|
-
savedBytes: Number.isFinite(partial.savedBytes) ? partial.savedBytes : 0,
|
|
35
|
-
savedTokens: Number.isFinite(partial.savedTokens) ? partial.savedTokens : 0,
|
|
36
|
-
notes: String(partial.notes || "").slice(0, MAX_NOTES_LEN),
|
|
37
|
-
artifactRef: partial.artifactRef ? String(partial.artifactRef).slice(0, MAX_ARTIFACT_LEN) : null,
|
|
38
|
-
meta: partial.meta || null,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
class ValueLedger {
|
|
43
|
-
constructor(repoRoot) {
|
|
44
|
-
this.repoRoot = repoRoot;
|
|
45
|
-
this.filePath = path.join(repoRoot, LEDGER_REL);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
append(partial) {
|
|
49
|
-
try {
|
|
50
|
-
const event = buildEvent(partial);
|
|
51
|
-
const dir = path.dirname(this.filePath);
|
|
52
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
53
|
-
fs.appendFileSync(this.filePath, JSON.stringify(event) + "\n", "utf8");
|
|
54
|
-
return event;
|
|
55
|
-
} catch {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
loadAll() {
|
|
61
|
-
try {
|
|
62
|
-
const raw = fs.readFileSync(this.filePath, "utf8");
|
|
63
|
-
return raw
|
|
64
|
-
.split("\n")
|
|
65
|
-
.filter(Boolean)
|
|
66
|
-
.map((line) => {
|
|
67
|
-
try {
|
|
68
|
-
return JSON.parse(line);
|
|
69
|
-
} catch {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
.filter(Boolean);
|
|
74
|
-
} catch {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function buildValueLedgerSummary(events) {
|
|
81
|
-
const byBucket = {};
|
|
82
|
-
let totalSavedBytes = 0;
|
|
83
|
-
let totalSavedTokens = 0;
|
|
84
|
-
for (const e of events) {
|
|
85
|
-
if (!e || !e.bucket) continue;
|
|
86
|
-
if (!byBucket[e.bucket]) byBucket[e.bucket] = { count: 0, savedBytes: 0, savedTokens: 0 };
|
|
87
|
-
byBucket[e.bucket].count++;
|
|
88
|
-
byBucket[e.bucket].savedBytes += e.savedBytes || 0;
|
|
89
|
-
byBucket[e.bucket].savedTokens += e.savedTokens || 0;
|
|
90
|
-
totalSavedBytes += e.savedBytes || 0;
|
|
91
|
-
totalSavedTokens += e.savedTokens || 0;
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
totalEvents: events.length,
|
|
95
|
-
totalSavedBytes,
|
|
96
|
-
totalSavedTokens,
|
|
97
|
-
byBucket,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function formatValueLedgerLine(summary) {
|
|
102
|
-
if (!summary || summary.totalEvents === 0) return null;
|
|
103
|
-
const parts = [];
|
|
104
|
-
if (summary.byBucket.large_output_referenced?.count) {
|
|
105
|
-
parts.push(`${summary.byBucket.large_output_referenced.count} MCP large outputs replaced`);
|
|
106
|
-
}
|
|
107
|
-
if (summary.byBucket.reentry_reused?.count) {
|
|
108
|
-
parts.push(`${summary.byBucket.reentry_reused.count} reentry selections bounded`);
|
|
109
|
-
}
|
|
110
|
-
if (summary.byBucket.context_avoided?.count) {
|
|
111
|
-
parts.push(`${summary.byBucket.context_avoided.count} candidate drops recorded`);
|
|
112
|
-
}
|
|
113
|
-
if (summary.totalSavedBytes > 0) {
|
|
114
|
-
parts.push(`~${Math.round(summary.totalSavedBytes / 1024)}KB saved (MCP replacements)`);
|
|
115
|
-
}
|
|
116
|
-
if (parts.length === 0) {
|
|
117
|
-
parts.push(`${summary.totalEvents} value events`);
|
|
118
|
-
}
|
|
119
|
-
return `Value ledger: ${parts.join(", ")}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
module.exports = {
|
|
123
|
-
ValueLedger,
|
|
124
|
-
buildEvent,
|
|
125
|
-
buildValueLedgerSummary,
|
|
126
|
-
formatValueLedgerLine,
|
|
127
|
-
VALID_BUCKETS,
|
|
128
|
-
SCHEMA_VERSION,
|
|
129
|
-
LEDGER_REL,
|
|
130
|
-
};
|
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// ── Value Proof Calibration ───────────────────────────────────────────────────
|
|
4
|
-
//
|
|
5
|
-
// Normalizes every important value metric into a proof object with:
|
|
6
|
-
// basis, evidence, confidence, valueClass, overclaimRisk, policy flags.
|
|
7
|
-
//
|
|
8
|
-
// valueClass definitions:
|
|
9
|
-
// measured — derived directly from observed local data or event counts
|
|
10
|
-
// estimated — derived from observable local inputs using a clear formula
|
|
11
|
-
// heuristic — derived from rule-of-thumb assumptions
|
|
12
|
-
// unavailable — not enough evidence
|
|
13
|
-
//
|
|
14
|
-
// This module is purely computational — no FS I/O, no LLM, no network.
|
|
15
|
-
|
|
16
|
-
// ── Proof builder ─────────────────────────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
function buildValueProof({
|
|
19
|
-
valueId,
|
|
20
|
-
label,
|
|
21
|
-
dimension,
|
|
22
|
-
value,
|
|
23
|
-
unit,
|
|
24
|
-
valueClass,
|
|
25
|
-
confidence,
|
|
26
|
-
basis,
|
|
27
|
-
method,
|
|
28
|
-
evidence = [],
|
|
29
|
-
caveats = [],
|
|
30
|
-
overclaimRisk,
|
|
31
|
-
needsMoreEvidence = false,
|
|
32
|
-
nextEvidenceToCollect = null,
|
|
33
|
-
}) {
|
|
34
|
-
const userFacingAllowed = valueClass !== "unavailable" && confidence !== "unavailable";
|
|
35
|
-
const dashboardAllowed = userFacingAllowed && (valueClass === "measured" || valueClass === "estimated" || valueClass === "heuristic");
|
|
36
|
-
const websiteAllowed = valueClass === "measured" && confidence === "high";
|
|
37
|
-
const pricingAllowed = false; // never allowed without real usage/billing data
|
|
38
|
-
const caveatRequired = valueClass === "heuristic" || valueClass === "estimated" || overclaimRisk === "medium" || overclaimRisk === "high";
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
valueId,
|
|
42
|
-
label,
|
|
43
|
-
dimension,
|
|
44
|
-
value,
|
|
45
|
-
unit,
|
|
46
|
-
valueClass,
|
|
47
|
-
confidence,
|
|
48
|
-
basis,
|
|
49
|
-
method,
|
|
50
|
-
evidence,
|
|
51
|
-
caveats,
|
|
52
|
-
overclaimRisk,
|
|
53
|
-
userFacingAllowed,
|
|
54
|
-
dashboardAllowed,
|
|
55
|
-
websiteAllowed,
|
|
56
|
-
pricingAllowed,
|
|
57
|
-
caveatRequired,
|
|
58
|
-
needsMoreEvidence,
|
|
59
|
-
nextEvidenceToCollect,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ── Time saved proof ──────────────────────────────────────────────────────────
|
|
64
|
-
|
|
65
|
-
function buildTimeSavedProof({ manualStepsAvoided, minMinutes, maxMinutes, evidence, capApplied }) {
|
|
66
|
-
const hasValue = manualStepsAvoided > 0;
|
|
67
|
-
|
|
68
|
-
if (!hasValue) {
|
|
69
|
-
return buildValueProof({
|
|
70
|
-
valueId: "timeSaved",
|
|
71
|
-
label: "Time Saved",
|
|
72
|
-
dimension: "time",
|
|
73
|
-
value: null,
|
|
74
|
-
unit: "minutes",
|
|
75
|
-
valueClass: "unavailable",
|
|
76
|
-
confidence: "unavailable",
|
|
77
|
-
basis: "No manual steps avoided detected",
|
|
78
|
-
method: "heuristic: manual steps avoided × 1–3 minutes",
|
|
79
|
-
evidence: [],
|
|
80
|
-
caveats: ["No manual steps avoided detected; cannot estimate time savings."],
|
|
81
|
-
overclaimRisk: "none",
|
|
82
|
-
needsMoreEvidence: true,
|
|
83
|
-
nextEvidenceToCollect: "Run work-control, session-context, and workspace-registry to detect manual steps avoided.",
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const caveats = [
|
|
88
|
-
"Heuristic estimate — no stopwatch or measured session duration.",
|
|
89
|
-
`Based on ${manualStepsAvoided} manual steps avoided × 1–3 minutes per step.`,
|
|
90
|
-
capApplied ? `Time estimate was capped at ${maxMinutes} minutes (max heuristic cap applied).` : null,
|
|
91
|
-
"Confidence cannot be high without measured session duration evidence.",
|
|
92
|
-
].filter(Boolean);
|
|
93
|
-
|
|
94
|
-
return buildValueProof({
|
|
95
|
-
valueId: "timeSaved",
|
|
96
|
-
label: "Time Saved",
|
|
97
|
-
dimension: "time",
|
|
98
|
-
value: { min: minMinutes, max: maxMinutes },
|
|
99
|
-
unit: "minutes",
|
|
100
|
-
valueClass: "heuristic",
|
|
101
|
-
confidence: manualStepsAvoided >= 5 ? "medium" : "low",
|
|
102
|
-
basis: `${manualStepsAvoided} manual steps avoided`,
|
|
103
|
-
method: "heuristic: manual steps avoided × 1–3 minutes, capped",
|
|
104
|
-
evidence,
|
|
105
|
-
caveats,
|
|
106
|
-
overclaimRisk: "low",
|
|
107
|
-
needsMoreEvidence: true,
|
|
108
|
-
nextEvidenceToCollect: "Session duration measurement or stopwatch evidence would upgrade confidence from heuristic to estimated.",
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ── Token / context proof ─────────────────────────────────────────────────────
|
|
113
|
-
|
|
114
|
-
function buildTokenReductionProof({
|
|
115
|
-
rawCandidateTokens,
|
|
116
|
-
rawConfidence,
|
|
117
|
-
rawSources,
|
|
118
|
-
compactHandoffTokens,
|
|
119
|
-
compactConfidence,
|
|
120
|
-
tokenReduction,
|
|
121
|
-
}) {
|
|
122
|
-
if (rawCandidateTokens === null || compactHandoffTokens === null) {
|
|
123
|
-
return buildValueProof({
|
|
124
|
-
valueId: "tokenReduction",
|
|
125
|
-
label: "Token / Context Reduction",
|
|
126
|
-
dimension: "tokens",
|
|
127
|
-
value: null,
|
|
128
|
-
unit: "tokens",
|
|
129
|
-
valueClass: "unavailable",
|
|
130
|
-
confidence: "unavailable",
|
|
131
|
-
basis: "rawCandidateTokens or compactHandoffTokens not available",
|
|
132
|
-
method: "candidate context size vs compact handoff size",
|
|
133
|
-
evidence: [],
|
|
134
|
-
caveats: ["Token reduction cannot be measured without both raw candidate context and compact handoff."],
|
|
135
|
-
overclaimRisk: "none",
|
|
136
|
-
needsMoreEvidence: true,
|
|
137
|
-
nextEvidenceToCollect: "Run workspace-registry for raw candidate size and session-context for compact handoff tokens.",
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (tokenReduction <= 0) {
|
|
142
|
-
return buildValueProof({
|
|
143
|
-
valueId: "tokenReduction",
|
|
144
|
-
label: "Token / Context Reduction",
|
|
145
|
-
dimension: "tokens",
|
|
146
|
-
value: 0,
|
|
147
|
-
unit: "tokens",
|
|
148
|
-
valueClass: "unavailable",
|
|
149
|
-
confidence: "unavailable",
|
|
150
|
-
basis: "Compact handoff is not smaller than raw candidate context",
|
|
151
|
-
method: "candidate context size vs compact handoff size",
|
|
152
|
-
evidence: rawSources,
|
|
153
|
-
caveats: ["Token reduction is zero or negative; no savings claim should be shown."],
|
|
154
|
-
overclaimRisk: "none",
|
|
155
|
-
needsMoreEvidence: true,
|
|
156
|
-
nextEvidenceToCollect: "Verify session-context compact handoff is correctly minimized.",
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Both available and positive reduction
|
|
161
|
-
const combinedConfidence = compactConfidence === "measured" && rawConfidence === "estimated" ? "medium"
|
|
162
|
-
: compactConfidence === "measured" && rawConfidence === "measured" ? "high"
|
|
163
|
-
: "low";
|
|
164
|
-
|
|
165
|
-
const caveats = [
|
|
166
|
-
"Raw candidate context is estimated from source file/receipt sizes — not a measured model context window load.",
|
|
167
|
-
"Token counts use chars/4 heuristic unless session-context provides a measured value.",
|
|
168
|
-
`Raw context labeled 'candidate': it represents what could have been loaded, not guaranteed user behavior.`,
|
|
169
|
-
];
|
|
170
|
-
if (combinedConfidence === "low") {
|
|
171
|
-
caveats.push("Low confidence: both raw and compact estimates are heuristic.");
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return buildValueProof({
|
|
175
|
-
valueId: "tokenReduction",
|
|
176
|
-
label: "Token / Context Reduction",
|
|
177
|
-
dimension: "tokens",
|
|
178
|
-
value: tokenReduction,
|
|
179
|
-
unit: "tokens",
|
|
180
|
-
valueClass: rawConfidence === "estimated" ? "estimated" : "heuristic",
|
|
181
|
-
confidence: combinedConfidence,
|
|
182
|
-
basis: `~${rawCandidateTokens.toLocaleString()} candidate tokens → ~${compactHandoffTokens.toLocaleString()} compact tokens`,
|
|
183
|
-
method: `raw estimate from: ${rawSources.join("; ")}; compact from session-context`,
|
|
184
|
-
evidence: rawSources,
|
|
185
|
-
caveats,
|
|
186
|
-
overclaimRisk: "low",
|
|
187
|
-
needsMoreEvidence: false,
|
|
188
|
-
nextEvidenceToCollect: "Local tokenizer integration would replace chars/4 heuristic with a measured value.",
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// ── Cost proof ────────────────────────────────────────────────────────────────
|
|
193
|
-
|
|
194
|
-
function buildCostProof({ hasLocalPricingSource, costEvidence = null }) {
|
|
195
|
-
if (!hasLocalPricingSource) {
|
|
196
|
-
return buildValueProof({
|
|
197
|
-
valueId: "costAvoided",
|
|
198
|
-
label: "Cost Avoided",
|
|
199
|
-
dimension: "cost",
|
|
200
|
-
value: null,
|
|
201
|
-
unit: "USD",
|
|
202
|
-
valueClass: "unavailable",
|
|
203
|
-
confidence: "unavailable",
|
|
204
|
-
basis: "No local pricing source available",
|
|
205
|
-
method: "requires local token pricing data",
|
|
206
|
-
evidence: [],
|
|
207
|
-
caveats: [
|
|
208
|
-
"Cost estimate unavailable: no local pricing source exists.",
|
|
209
|
-
"Do not derive cost savings from generic internet pricing.",
|
|
210
|
-
"Run `avorelo pricing --init` to create a local pricing config.",
|
|
211
|
-
"Token reduction is shown instead.",
|
|
212
|
-
],
|
|
213
|
-
overclaimRisk: "high",
|
|
214
|
-
needsMoreEvidence: true,
|
|
215
|
-
nextEvidenceToCollect: "Local pricing config required. Run `avorelo pricing --init`.",
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Pricing source exists but no computed cost evidence
|
|
220
|
-
if (!costEvidence || costEvidence.valueClass === "unavailable" || costEvidence.costAvoidedEstimate === null) {
|
|
221
|
-
const caveats = ["Pricing source available but cost estimate could not be computed."];
|
|
222
|
-
if (costEvidence && costEvidence.caveats) caveats.push(...costEvidence.caveats.slice(0, 2));
|
|
223
|
-
return buildValueProof({
|
|
224
|
-
valueId: "costAvoided",
|
|
225
|
-
label: "Cost Avoided",
|
|
226
|
-
dimension: "cost",
|
|
227
|
-
value: null,
|
|
228
|
-
unit: "USD",
|
|
229
|
-
valueClass: "unavailable",
|
|
230
|
-
confidence: "unavailable",
|
|
231
|
-
basis: costEvidence ? costEvidence.formula || "insufficient token evidence" : "insufficient token evidence",
|
|
232
|
-
method: "token reduction × per-token price",
|
|
233
|
-
evidence: [],
|
|
234
|
-
caveats,
|
|
235
|
-
overclaimRisk: "medium",
|
|
236
|
-
needsMoreEvidence: true,
|
|
237
|
-
nextEvidenceToCollect: "Token evidence required. Run `avorelo token-evidence --json`.",
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Both pricing and token evidence available — produce estimated cost proof
|
|
242
|
-
const estimate = costEvidence.costAvoidedEstimate;
|
|
243
|
-
const confidence = costEvidence.confidence || "low";
|
|
244
|
-
const caveats = (costEvidence.caveats || []).slice(0, 3);
|
|
245
|
-
|
|
246
|
-
return buildValueProof({
|
|
247
|
-
valueId: "costAvoided",
|
|
248
|
-
label: "Cost Avoided",
|
|
249
|
-
dimension: "cost",
|
|
250
|
-
value: estimate,
|
|
251
|
-
unit: costEvidence.currency || "USD",
|
|
252
|
-
valueClass: "estimated",
|
|
253
|
-
confidence,
|
|
254
|
-
basis: costEvidence.formula || `estimated from avoided tokens × local pricing`,
|
|
255
|
-
method: "candidate token reduction × local pricing source",
|
|
256
|
-
evidence: [costEvidence.pricingSource || "local_pricing", "token_evidence"],
|
|
257
|
-
caveats,
|
|
258
|
-
overclaimRisk: "medium",
|
|
259
|
-
needsMoreEvidence: true,
|
|
260
|
-
nextEvidenceToCollect: "Provider usage API would replace estimated tokens with measured values.",
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// ── Security proofs ───────────────────────────────────────────────────────────
|
|
265
|
-
|
|
266
|
-
function buildSecurityProofs({
|
|
267
|
-
risksSurfaced,
|
|
268
|
-
risksRouted,
|
|
269
|
-
risksBlocked,
|
|
270
|
-
approvalsRequired,
|
|
271
|
-
reducedScopeRecommendations,
|
|
272
|
-
reviewRequiredItems,
|
|
273
|
-
highRiskAssetsInRegistry,
|
|
274
|
-
intakePresent,
|
|
275
|
-
safePathPresent,
|
|
276
|
-
}) {
|
|
277
|
-
const proofs = [];
|
|
278
|
-
|
|
279
|
-
// Risks surfaced proof
|
|
280
|
-
if (risksSurfaced > 0) {
|
|
281
|
-
proofs.push(buildValueProof({
|
|
282
|
-
valueId: "risksSurfaced",
|
|
283
|
-
label: "Risks Surfaced",
|
|
284
|
-
dimension: "security",
|
|
285
|
-
value: risksSurfaced,
|
|
286
|
-
unit: "items",
|
|
287
|
-
valueClass: "measured",
|
|
288
|
-
confidence: "high",
|
|
289
|
-
basis: "install-intake receipt: high/critical-risk item counts",
|
|
290
|
-
method: "direct count from install-intake scan receipt",
|
|
291
|
-
evidence: ["install-intake"],
|
|
292
|
-
caveats: ["Surfaced means detected and flagged — not necessarily blocked or mitigated."],
|
|
293
|
-
overclaimRisk: "none",
|
|
294
|
-
needsMoreEvidence: false,
|
|
295
|
-
nextEvidenceToCollect: null,
|
|
296
|
-
}));
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// Risks blocked proof (safe-path block decision)
|
|
300
|
-
if (safePathPresent) {
|
|
301
|
-
proofs.push(buildValueProof({
|
|
302
|
-
valueId: "risksBlocked",
|
|
303
|
-
label: "Risks Blocked",
|
|
304
|
-
dimension: "security",
|
|
305
|
-
value: risksBlocked,
|
|
306
|
-
unit: "actions",
|
|
307
|
-
valueClass: risksBlocked > 0 ? "measured" : "measured",
|
|
308
|
-
confidence: "high",
|
|
309
|
-
basis: "safe-path receipt: block decision count",
|
|
310
|
-
method: "direct count from safe-path receipt: safePathDecision === 'block'",
|
|
311
|
-
evidence: ["safe-path"],
|
|
312
|
-
caveats: risksBlocked === 0 ? ["Safe Path ran but no block decision was made."] : [],
|
|
313
|
-
overclaimRisk: "none",
|
|
314
|
-
needsMoreEvidence: false,
|
|
315
|
-
nextEvidenceToCollect: null,
|
|
316
|
-
}));
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Risks routed proof
|
|
320
|
-
if (safePathPresent && risksRouted > 0) {
|
|
321
|
-
proofs.push(buildValueProof({
|
|
322
|
-
valueId: "risksRouted",
|
|
323
|
-
label: "Risks Routed via Safe Path",
|
|
324
|
-
dimension: "security",
|
|
325
|
-
value: risksRouted,
|
|
326
|
-
unit: "actions",
|
|
327
|
-
valueClass: "measured",
|
|
328
|
-
confidence: "high",
|
|
329
|
-
basis: "safe-path receipt: approval_required / recommend_reduced_scope / warn_with_boundary decision",
|
|
330
|
-
method: "direct count from safe-path receipt decision field",
|
|
331
|
-
evidence: ["safe-path"],
|
|
332
|
-
caveats: [],
|
|
333
|
-
overclaimRisk: "none",
|
|
334
|
-
needsMoreEvidence: false,
|
|
335
|
-
nextEvidenceToCollect: null,
|
|
336
|
-
}));
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Registry-only high-risk assets (surfaced, not blocked)
|
|
340
|
-
if (highRiskAssetsInRegistry > 0 && !safePathPresent) {
|
|
341
|
-
proofs.push(buildValueProof({
|
|
342
|
-
valueId: "highRiskAssetsFoundInRegistry",
|
|
343
|
-
label: "High-Risk Assets in Registry",
|
|
344
|
-
dimension: "security",
|
|
345
|
-
value: highRiskAssetsInRegistry,
|
|
346
|
-
unit: "assets",
|
|
347
|
-
valueClass: "measured",
|
|
348
|
-
confidence: "medium",
|
|
349
|
-
basis: "workspace-registry: highRiskAssets count",
|
|
350
|
-
method: "direct count from workspace-registry summary",
|
|
351
|
-
evidence: ["workspace-registry"],
|
|
352
|
-
caveats: [
|
|
353
|
-
"Registry-detected high-risk assets are surfaced only — Safe Path was not run.",
|
|
354
|
-
"These assets have NOT been blocked or routed; they require manual review.",
|
|
355
|
-
],
|
|
356
|
-
overclaimRisk: "medium",
|
|
357
|
-
needsMoreEvidence: true,
|
|
358
|
-
nextEvidenceToCollect: "Run safe-path to route/block high-risk assets.",
|
|
359
|
-
}));
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
return proofs;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// ── Clarity / seamlessness proofs ─────────────────────────────────────────────
|
|
366
|
-
|
|
367
|
-
function buildClarityProofs({ nextActionPresent, doNotRepeatCount, relevantCommandsCount, targetHandoffPrepared, proofAvailable }) {
|
|
368
|
-
const score = [nextActionPresent, doNotRepeatCount > 0, relevantCommandsCount > 0, targetHandoffPrepared, proofAvailable].filter(Boolean).length;
|
|
369
|
-
const confidence = score >= 4 ? "medium" : score >= 2 ? "low" : "unavailable";
|
|
370
|
-
|
|
371
|
-
return [buildValueProof({
|
|
372
|
-
valueId: "clarityScore",
|
|
373
|
-
label: "Clarity Score",
|
|
374
|
-
dimension: "clarity",
|
|
375
|
-
value: score,
|
|
376
|
-
unit: "of 5 checks",
|
|
377
|
-
valueClass: score >= 3 ? "measured" : "estimated",
|
|
378
|
-
confidence,
|
|
379
|
-
basis: `${score}/5 clarity checks passed`,
|
|
380
|
-
method: "count of: nextAction, doNotRepeat, relevantCommands, handoff, proof",
|
|
381
|
-
evidence: [nextActionPresent ? "work-control" : null, targetHandoffPrepared ? "session-context" : null].filter(Boolean),
|
|
382
|
-
caveats: score < 3 ? ["Clarity is partial — not all surfaces are ready."] : [],
|
|
383
|
-
overclaimRisk: "none",
|
|
384
|
-
needsMoreEvidence: score < 5,
|
|
385
|
-
nextEvidenceToCollect: score < 5 ? "Run missing Avorelo surfaces to complete clarity score." : null,
|
|
386
|
-
})];
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// ── Calibration report ────────────────────────────────────────────────────────
|
|
390
|
-
|
|
391
|
-
function buildCalibrationReport(proofs) {
|
|
392
|
-
const allProofs = [].concat(...proofs.map((p) => Array.isArray(p) ? p : [p]));
|
|
393
|
-
|
|
394
|
-
const measured = allProofs.filter((p) => p.valueClass === "measured" && p.value !== null);
|
|
395
|
-
const estimated = allProofs.filter((p) => p.valueClass === "estimated" && p.value !== null);
|
|
396
|
-
const heuristic = allProofs.filter((p) => p.valueClass === "heuristic" && p.value !== null);
|
|
397
|
-
const unavailable = allProofs.filter((p) => p.valueClass === "unavailable");
|
|
398
|
-
const highOverclaim = allProofs.filter((p) => p.overclaimRisk === "high" || p.overclaimRisk === "medium");
|
|
399
|
-
|
|
400
|
-
// Determine overall verdict
|
|
401
|
-
let overallVerdict;
|
|
402
|
-
if (measured.length === 0 && estimated.length === 0 && heuristic.length === 0) {
|
|
403
|
-
overallVerdict = "insufficient_data";
|
|
404
|
-
} else if (highOverclaim.length > 0) {
|
|
405
|
-
overallVerdict = "show_with_caveats";
|
|
406
|
-
} else if (measured.length > 0 || estimated.length > 0) {
|
|
407
|
-
overallVerdict = "safe_to_show";
|
|
408
|
-
} else {
|
|
409
|
-
overallVerdict = "show_with_caveats";
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
const strongestClaims = [
|
|
413
|
-
...measured.map((p) => `${p.label}: ${p.valueClass}, ${p.confidence} confidence`),
|
|
414
|
-
...estimated.map((p) => `${p.label}: ${p.valueClass}, ${p.confidence} confidence`),
|
|
415
|
-
].slice(0, 5);
|
|
416
|
-
|
|
417
|
-
const weakestClaims = [
|
|
418
|
-
...heuristic.map((p) => `${p.label}: heuristic — ${p.caveats[0] || "no stopwatch evidence"}`),
|
|
419
|
-
...unavailable.map((p) => `${p.label}: unavailable — ${p.basis}`),
|
|
420
|
-
].slice(0, 5);
|
|
421
|
-
|
|
422
|
-
const overclaimRisks = highOverclaim.map((p) => ({
|
|
423
|
-
valueId: p.valueId,
|
|
424
|
-
risk: p.overclaimRisk,
|
|
425
|
-
reason: p.caveats[0] || "overclaim risk detected",
|
|
426
|
-
}));
|
|
427
|
-
|
|
428
|
-
const recommendedCopySafe = [];
|
|
429
|
-
if (measured.some((p) => p.valueId === "risksSurfaced")) {
|
|
430
|
-
recommendedCopySafe.push("\"Risky items surfaced before execution\" (measured from intake receipt)");
|
|
431
|
-
}
|
|
432
|
-
if (estimated.some((p) => p.valueId === "tokenReduction") || measured.some((p) => p.valueId === "tokenReduction")) {
|
|
433
|
-
recommendedCopySafe.push("\"Estimated candidate context avoided\" (with caveat about estimation method)");
|
|
434
|
-
}
|
|
435
|
-
if (heuristic.some((p) => p.valueId === "timeSaved")) {
|
|
436
|
-
recommendedCopySafe.push("\"Estimated N–M minutes saved\" (labeled as heuristic estimate with range)");
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
const blockedCopy = [
|
|
440
|
-
"\"Guaranteed ROI\" — no measured stopwatch or billing data",
|
|
441
|
-
"\"$X saved\" — no local pricing source available",
|
|
442
|
-
"\"N risks blocked\" — only use when safe-path block decision is present",
|
|
443
|
-
"\"Exact N minutes saved\" — only ranges supported for heuristic estimates",
|
|
444
|
-
];
|
|
445
|
-
|
|
446
|
-
const nextEvidenceToCollect = [
|
|
447
|
-
...new Set(
|
|
448
|
-
allProofs
|
|
449
|
-
.filter((p) => p.needsMoreEvidence && p.nextEvidenceToCollect)
|
|
450
|
-
.map((p) => p.nextEvidenceToCollect)
|
|
451
|
-
),
|
|
452
|
-
].slice(0, 5);
|
|
453
|
-
|
|
454
|
-
return {
|
|
455
|
-
overallVerdict,
|
|
456
|
-
measuredCount: measured.length,
|
|
457
|
-
estimatedCount: estimated.length,
|
|
458
|
-
heuristicCount: heuristic.length,
|
|
459
|
-
unavailableCount: unavailable.length,
|
|
460
|
-
strongestClaims,
|
|
461
|
-
weakestClaims,
|
|
462
|
-
overclaimRisks,
|
|
463
|
-
recommendedCopySafe,
|
|
464
|
-
blockedCopy,
|
|
465
|
-
nextEvidenceToCollect,
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// ── Build all proofs from operating value inputs ──────────────────────────────
|
|
470
|
-
|
|
471
|
-
function buildValueProofs({
|
|
472
|
-
manualStepsAvoided,
|
|
473
|
-
minMinutes,
|
|
474
|
-
maxMinutes,
|
|
475
|
-
timeSavedEvidence,
|
|
476
|
-
capApplied,
|
|
477
|
-
rawCandidateTokens,
|
|
478
|
-
rawConfidence,
|
|
479
|
-
rawSources,
|
|
480
|
-
compactHandoffTokens,
|
|
481
|
-
compactConfidence,
|
|
482
|
-
tokenReduction,
|
|
483
|
-
hasLocalPricingSource,
|
|
484
|
-
costEvidence,
|
|
485
|
-
risksSurfaced,
|
|
486
|
-
risksRouted,
|
|
487
|
-
risksBlocked,
|
|
488
|
-
approvalsRequired,
|
|
489
|
-
reducedScopeRecommendations,
|
|
490
|
-
reviewRequiredItems,
|
|
491
|
-
highRiskAssetsInRegistry,
|
|
492
|
-
intakePresent,
|
|
493
|
-
safePathPresent,
|
|
494
|
-
nextActionPresent,
|
|
495
|
-
doNotRepeatCount,
|
|
496
|
-
relevantCommandsCount,
|
|
497
|
-
targetHandoffPrepared,
|
|
498
|
-
proofAvailable,
|
|
499
|
-
}) {
|
|
500
|
-
const timeSavedProof = buildTimeSavedProof({ manualStepsAvoided, minMinutes, maxMinutes, evidence: timeSavedEvidence || [], capApplied });
|
|
501
|
-
const tokenReductionProof = buildTokenReductionProof({ rawCandidateTokens, rawConfidence, rawSources, compactHandoffTokens, compactConfidence, tokenReduction });
|
|
502
|
-
const costProof = buildCostProof({ hasLocalPricingSource: hasLocalPricingSource || false, costEvidence: costEvidence || null });
|
|
503
|
-
const securityProofs = buildSecurityProofs({ risksSurfaced, risksRouted, risksBlocked, approvalsRequired, reducedScopeRecommendations, reviewRequiredItems, highRiskAssetsInRegistry, intakePresent, safePathPresent });
|
|
504
|
-
const clarityProofs = buildClarityProofs({ nextActionPresent, doNotRepeatCount, relevantCommandsCount, targetHandoffPrepared, proofAvailable });
|
|
505
|
-
|
|
506
|
-
const allProofs = [timeSavedProof, tokenReductionProof, costProof, ...securityProofs, ...clarityProofs];
|
|
507
|
-
const calibrationReport = buildCalibrationReport(allProofs);
|
|
508
|
-
|
|
509
|
-
return { proofs: allProofs, calibrationReport };
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
// ── Compact user-facing confidence label ─────────────────────────────────────
|
|
513
|
-
|
|
514
|
-
function confidenceLabel(valueClass, confidence) {
|
|
515
|
-
if (valueClass === "unavailable" || confidence === "unavailable") return null;
|
|
516
|
-
return `${valueClass}, ${confidence} confidence`;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// ── Exports ───────────────────────────────────────────────────────────────────
|
|
520
|
-
|
|
521
|
-
module.exports = {
|
|
522
|
-
buildValueProof,
|
|
523
|
-
buildTimeSavedProof,
|
|
524
|
-
buildTokenReductionProof,
|
|
525
|
-
buildCostProof,
|
|
526
|
-
buildSecurityProofs,
|
|
527
|
-
buildClarityProofs,
|
|
528
|
-
buildCalibrationReport,
|
|
529
|
-
buildValueProofs,
|
|
530
|
-
confidenceLabel,
|
|
531
|
-
};
|