@lsctech/polaris 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * SOL scorecard schema.
4
+ *
5
+ * Defines durable, reproducible scorecards for SOL evaluation subjects
6
+ * (Foreman, workers, providers, models, routing decisions, token efficiency,
7
+ * QC outcomes, and user/Foreman intervention). Scorecards are distinct from
8
+ * the run-level SolScoreReport: they are per-scope, carry explicit formula
9
+ * versions, source references, and recommendation inputs.
10
+ *
11
+ * Architecture reference: sol-evaluation-report-architecture.md §Artifact classes
12
+ *
13
+ * Design rules:
14
+ * - Every scorecard carries a formula_version so consumers can detect drift.
15
+ * - source_refs link back to the immutable raw evidence that produced the scorecard.
16
+ * - Missing evidence results in SolScorecardAvailability="skipped" with reasons.
17
+ * - Scorecards are derived and reproducible; raw evidence always wins on conflict.
18
+ * - Existing SolScoreReport (run-level evaluation) remains unchanged.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.WORKER_QUALITY_PER_TOKEN_SPEC = exports.FOREMAN_QUALITY_PER_TOKEN_SPEC = exports.WORKER_TOKEN_EFFICIENCY_SPEC = exports.FOREMAN_TOKEN_EFFICIENCY_SPEC = exports.SOL_FORMULA_VERSIONS = void 0;
22
+ exports.buildRecommendationInputs = buildRecommendationInputs;
23
+ exports.computeAggregateScore = computeAggregateScore;
24
+ exports.determineScorecardAvailability = determineScorecardAvailability;
25
+ // ──────────────────────────────────────────────
26
+ // Helpers: formula version constants
27
+ // ──────────────────────────────────────────────
28
+ /**
29
+ * Named formula version constants.
30
+ * Use these in subscore and aggregate formula_version fields.
31
+ */
32
+ exports.SOL_FORMULA_VERSIONS = {
33
+ TOKEN_EFFICIENCY_V1: "token-efficiency/1.0",
34
+ QUALITY_PER_TOKEN_V1: "quality-per-token/1.0",
35
+ COMPOSITE_MEAN_V1: "composite-mean/1.0",
36
+ VALIDATION_BINARY_V1: "validation-binary/1.0",
37
+ DISPATCH_RATE_V1: "dispatch-rate/1.0",
38
+ INTERVENTION_BINARY_V1: "intervention-binary/1.0",
39
+ QC_REPAIR_LOOP_V1: "qc-repair-loop/1.0",
40
+ SCOPE_ADHERENCE_V1: "scope-adherence/1.0",
41
+ STARTUP_FAILURE_RATE_V1: "startup-failure-rate/1.0",
42
+ QUOTA_EXHAUSTION_RATE_V1: "quota-exhaustion-rate/1.0",
43
+ FALLBACK_FREQUENCY_V1: "fallback-frequency/1.0",
44
+ ROLE_SUITABILITY_V1: "role-suitability/1.0",
45
+ RUNTIME_PROXY_V1: "runtime-proxy/1.0",
46
+ QUALITY_OUTCOMES_V1: "quality-outcomes/1.0",
47
+ ROUTE_SELECTED_V1: "route-selected/1.0",
48
+ ROUTE_CANDIDATES_V1: "route-candidates/1.0",
49
+ ROUTE_FALLBACK_PATH_V1: "route-fallback-path/1.0",
50
+ ROUTE_OUTCOME_QUALITY_V1: "route-outcome-quality/1.0",
51
+ ROUTE_TOKEN_BURN_V1: "route-token-burn/1.0",
52
+ ROUTE_QC_RESULT_V1: "route-qc-result/1.0",
53
+ ROUTE_VALIDATION_RESULT_V1: "route-validation-result/1.0",
54
+ ROUTE_CONFIRMED_SIGNAL_V1: "route-confirmed-signal/1.0",
55
+ };
56
+ /**
57
+ * Token efficiency formula spec for the Foreman subject (v1.0).
58
+ * Budget = 150k tokens; 0.0 at 300k tokens.
59
+ */
60
+ exports.FOREMAN_TOKEN_EFFICIENCY_SPEC = {
61
+ formula_version: "token-efficiency/1.0",
62
+ budget: 150_000,
63
+ max_penalized: 300_000,
64
+ source_event_type: "bootstrap-context-size",
65
+ };
66
+ /**
67
+ * Token efficiency formula spec for the Worker subject (v1.0).
68
+ * Budget = 200k tokens; 0.0 at 500k tokens.
69
+ */
70
+ exports.WORKER_TOKEN_EFFICIENCY_SPEC = {
71
+ formula_version: "token-efficiency/1.0",
72
+ budget: 200_000,
73
+ max_penalized: 500_000,
74
+ source_event_type: "worker-heartbeat-tokens",
75
+ };
76
+ /**
77
+ * Quality-per-token formula spec for run-level (Foreman) subject (v1.0).
78
+ */
79
+ exports.FOREMAN_QUALITY_PER_TOKEN_SPEC = {
80
+ formula_version: "quality-per-token/1.0",
81
+ budget_denominator: 150_000,
82
+ subject: "foreman",
83
+ };
84
+ /**
85
+ * Quality-per-token formula spec for per-child (Worker) subject (v1.0).
86
+ */
87
+ exports.WORKER_QUALITY_PER_TOKEN_SPEC = {
88
+ formula_version: "quality-per-token/1.0",
89
+ budget_denominator: 200_000,
90
+ subject: "worker",
91
+ };
92
+ // ──────────────────────────────────────────────
93
+ // Helpers: scorecard construction utilities
94
+ // ──────────────────────────────────────────────
95
+ /**
96
+ * Build SolRecommendationInputs from a list of subscores and raw metrics.
97
+ * Applies the 0.6 threshold for below_threshold detection.
98
+ */
99
+ function buildRecommendationInputs(subscores, rawMetrics, aggregateScore) {
100
+ const THRESHOLD = 0.6;
101
+ const lowScoringDimensions = subscores
102
+ .filter((s) => s.score !== null && s.score < 0.5)
103
+ .map((s) => s.dimension);
104
+ const skippedDimensions = subscores
105
+ .filter((s) => s.score === null)
106
+ .map((s) => s.dimension);
107
+ return {
108
+ below_threshold: aggregateScore !== null && aggregateScore < THRESHOLD,
109
+ low_scoring_dimensions: lowScoringDimensions,
110
+ skipped_dimensions: skippedDimensions,
111
+ over_token_budget: (rawMetrics.max_bootstrap_tokens !== null &&
112
+ rawMetrics.max_bootstrap_tokens > exports.FOREMAN_TOKEN_EFFICIENCY_SPEC.budget) ||
113
+ (rawMetrics.worker_tokens_used !== null &&
114
+ rawMetrics.worker_tokens_used > exports.WORKER_TOKEN_EFFICIENCY_SPEC.budget),
115
+ intervention_detected: rawMetrics.user_intervened === true || rawMetrics.foreman_intervened === true,
116
+ router_issue_detected: rawMetrics.router_fallback_used === true || rawMetrics.router_exhausted === true,
117
+ qc_issue_detected: (rawMetrics.qc_blocking_findings !== null && rawMetrics.qc_blocking_findings > 0) ||
118
+ rawMetrics.qc_repair_loop_status === "all-providers-failed" ||
119
+ rawMetrics.qc_repair_loop_status === "operator-review",
120
+ notes: [],
121
+ };
122
+ }
123
+ /**
124
+ * Compute aggregate score from subscores (simple mean of non-null scores).
125
+ * Returns null when all subscores are skipped.
126
+ */
127
+ function computeAggregateScore(subscores) {
128
+ const scored = subscores.filter((s) => s.score !== null);
129
+ if (scored.length === 0)
130
+ return null;
131
+ const mean = scored.reduce((sum, s) => sum + s.score, 0) / scored.length;
132
+ return Number(mean.toFixed(4));
133
+ }
134
+ /**
135
+ * Determine scorecard availability from subscores.
136
+ * "complete" when all subscores have scores; "partial" when some are skipped;
137
+ * "skipped" when all are skipped; "unavailable" when subscores is empty.
138
+ */
139
+ function determineScorecardAvailability(subscores) {
140
+ if (subscores.length === 0)
141
+ return "unavailable";
142
+ const scored = subscores.filter((s) => s.score !== null).length;
143
+ if (scored === 0)
144
+ return "skipped";
145
+ if (scored < subscores.length)
146
+ return "partial";
147
+ return "complete";
148
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsctech/polaris",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "Polaris — standalone taskchain orchestration framework for governed AI agent workflows",
5
5
  "bin": {
6
6
  "polaris": "dist/cli/index.js",