sigrank 0.18.5 → 1.0.1

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/MCP_SERVER_DESCRIPTION.md +172 -0
  3. package/README.md +94 -41
  4. package/adapters/index.mjs +1100 -0
  5. package/adapters/tokenpull.mjs +568 -0
  6. package/adapters.mjs +1 -857
  7. package/analytics/cascade.mjs +338 -0
  8. package/cascade.mjs +1 -274
  9. package/cli.mjs +1 -1853
  10. package/connect.mjs +1 -13
  11. package/identity/connect.mjs +13 -0
  12. package/identity/keystore.mjs +231 -0
  13. package/identity/sign.mjs +106 -0
  14. package/index.mjs +47 -162
  15. package/keystore.mjs +1 -242
  16. package/lib/constants.mjs +137 -0
  17. package/lib/pkg-version.mjs +59 -0
  18. package/manifest.json +46 -0
  19. package/narrate.mjs +1 -77
  20. package/package.json +41 -16
  21. package/preflight.mjs +1 -191
  22. package/presentation/cli.mjs +1926 -0
  23. package/presentation/narrate.mjs +219 -0
  24. package/presentation/tui-themes.mjs +189 -0
  25. package/presentation/tui.mjs +3316 -0
  26. package/prompts/check-my-efficiency.md +1 -0
  27. package/prompts/compare-with-leader.md +1 -0
  28. package/prompts/simulate-improvement.md +1 -0
  29. package/proxy.mjs +492 -0
  30. package/resources/class-tiers.md +81 -0
  31. package/resources/data-policy.md +31 -0
  32. package/resources/install-guide.md +59 -0
  33. package/resources/privacy-model.md +44 -0
  34. package/resources/scoring-formula.md +24 -0
  35. package/review.mjs +263 -0
  36. package/sign.mjs +1 -106
  37. package/submit/index.mjs +297 -0
  38. package/submit/preflight.mjs +191 -0
  39. package/submit.mjs +1 -303
  40. package/tokenpull.mjs +1 -576
  41. package/tokscale_analytics.mjs +864 -0
  42. package/tools/_framing.mjs +217 -0
  43. package/tools/_helpers.mjs +253 -0
  44. package/tools/_peer-matching.mjs +361 -0
  45. package/tools/_report.mjs +262 -0
  46. package/tools/_schemas.mjs +492 -0
  47. package/tools/_verifiers.mjs +148 -0
  48. package/tools/compare-operators.mjs +80 -0
  49. package/tools/compare-self.mjs +124 -0
  50. package/tools/describe-power-user.mjs +78 -0
  51. package/tools/diagnose-cascade.mjs +192 -0
  52. package/tools/discover-peers.mjs +198 -0
  53. package/tools/enroll.mjs +119 -0
  54. package/tools/get-best-operator.mjs +59 -0
  55. package/tools/get-leaderboard.mjs +27 -0
  56. package/tools/get-operator.mjs +33 -0
  57. package/tools/index.mjs +229 -0
  58. package/tools/optimize-efficiency.mjs +170 -0
  59. package/tools/rank-paste.mjs +51 -0
  60. package/tools/rank-windows.mjs +120 -0
  61. package/tools/self-improve.mjs +423 -0
  62. package/tools/simulate-change.mjs +207 -0
  63. package/tools/submit-paste.mjs +121 -0
  64. package/tools/submit-verified.mjs +153 -0
  65. package/tools/suggest-improvements.mjs +168 -0
  66. package/tools/tokenpull-compare.mjs +123 -0
  67. package/tools/tokenpull-submit.mjs +235 -0
  68. package/tools/tokenpull.mjs +113 -0
  69. package/tools/tokscale-breakdown.mjs +119 -0
  70. package/tools/tokscale-competitive-intel.mjs +45 -0
  71. package/tools/tokscale-cost-analysis.mjs +31 -0
  72. package/tools/tokscale-developer-profile.mjs +36 -0
  73. package/tools/tokscale-device-profile.mjs +35 -0
  74. package/tools/tokscale-market-share.mjs +38 -0
  75. package/tools/tokscale-mcp-usage.mjs +33 -0
  76. package/tools/tokscale-model-trends.mjs +32 -0
  77. package/tools/watch-tokenpull.mjs +134 -0
  78. package/tools.mjs +1 -3897
  79. package/tui.mjs +4 -2650
  80. package/banner.svg +0 -7
package/preflight.mjs CHANGED
@@ -1,191 +1 @@
1
- /**
2
- * preflight.mjs — local plausibility pre-checks for the MCP submit path.
3
- *
4
- * Mirrors ONLY the server's public plausibility gate (gates.ts:86-137) —
5
- * totals consistency, turns/sessions ratios, output rate, cache ratio,
6
- * cadence. These are integrity guards labeled "NOT the proprietary RS.xx"
7
- * and are safe to replicate in an open agent.
8
- *
9
- * The proprietary battery (Benford / cadence / contamination) is SERVER-ONLY
10
- * and must NOT be shipped in the agent. The server always runs its own
11
- * battery after the POST — this preflight is a client-side preview of the
12
- * public plausibility checks only, not a replacement for the full gate chain.
13
- *
14
- * If preflight flags, the operator sees WHY their submission would be
15
- * rejected or flagged, and can fix the issue or submit anyway.
16
- *
17
- * Source of truth: lib/ingest/gates.ts (plausibilityGate). This port must
18
- * stay in sync with the plausibility gate ONLY.
19
- */
20
-
21
- // ── plausibility checks (from gates.ts:86-137) ──────────────────────────────
22
-
23
- const GATE_LIMITS = {
24
- TOTALS_TOLERANCE_FRAC: 0.01,
25
- MAX_OUTPUT_TOKENS_PER_MIN: 20_000,
26
- // Tightened range-plausibility bounds (deviewreview3)
27
- MAX_CACHE_REUSE_RATIO: 35,
28
- MIN_CACHE_WRITE_RATIO: 0.5,
29
- MIN_INPUT_SHARE_FRAC: 0.0003,
30
- MAX_CADENCE_PER_MIN: 15,
31
- };
32
-
33
- /**
34
- * Run plausibility checks against a payload's raw_telemetry.
35
- * Returns array of issues: { severity, code, detail }
36
- */
37
- export function plausibilityCheck(rt, window) {
38
- const out = [];
39
- const pillars =
40
- rt.tokens_input_fresh +
41
- rt.tokens_output +
42
- rt.tokens_cache_read +
43
- rt.tokens_cache_creation;
44
-
45
- if (rt.tokens_total > 0) {
46
- const tol = Math.max(
47
- 1,
48
- rt.tokens_total * GATE_LIMITS.TOTALS_TOLERANCE_FRAC,
49
- );
50
- if (Math.abs(pillars - rt.tokens_total) > tol) {
51
- out.push({
52
- severity: "reject",
53
- code: "totals_inconsistent",
54
- detail: `Σ4 pillars (${pillars}) ≠ tokens_total (${rt.tokens_total})`,
55
- });
56
- }
57
- if (rt.sessions_count === 0) {
58
- out.push({
59
- severity: "reject",
60
- code: "tokens_without_sessions",
61
- detail: `tokens_total ${rt.tokens_total} with sessions_count 0`,
62
- });
63
- }
64
- }
65
- if (rt.turns_total < rt.sessions_count) {
66
- out.push({
67
- severity: "reject",
68
- code: "turns_lt_sessions",
69
- detail: `turns_total ${rt.turns_total} < sessions_count ${rt.sessions_count}`,
70
- });
71
- }
72
- if (rt.tokens_output > 0 && rt.turns_total === 0) {
73
- out.push({
74
- severity: "reject",
75
- code: "output_without_turns",
76
- detail: `tokens_output ${rt.tokens_output} with turns_total 0`,
77
- });
78
- }
79
-
80
- if (window) {
81
- const spanMin =
82
- (Date.parse(window.end) - Date.parse(window.start)) / 60_000;
83
- if (Number.isFinite(spanMin) && rt.active_minutes_est > spanMin + 1) {
84
- out.push({
85
- severity: "flag",
86
- code: "active_exceeds_window",
87
- detail: `active_minutes_est ${rt.active_minutes_est} > window span ${Math.round(spanMin)}m`,
88
- });
89
- }
90
- }
91
-
92
- const outPerMin = rt.tokens_output / Math.max(rt.active_minutes_est, 1);
93
- if (outPerMin > GATE_LIMITS.MAX_OUTPUT_TOKENS_PER_MIN) {
94
- out.push({
95
- severity: "flag",
96
- code: "implausible_output_rate",
97
- detail: `${Math.round(outPerMin)} output tok/min > ${GATE_LIMITS.MAX_OUTPUT_TOKENS_PER_MIN}`,
98
- });
99
- }
100
-
101
- // Cross-field ratio checks (defense-in-depth — also in the plausibility gate)
102
- // Bounds tightened (deviewreview3): original 100:1 + 50/min were too loose.
103
- if (rt.tokens_cache_read > 1_000 && rt.tokens_cache_creation === 0) {
104
- out.push({
105
- severity: "flag",
106
- code: "cache_without_creation",
107
- detail: `${rt.tokens_cache_read} cache_read with 0 cache_creation (impossible cascade)`,
108
- });
109
- }
110
- if (
111
- rt.tokens_cache_creation > 0 &&
112
- rt.tokens_cache_read / rt.tokens_cache_creation >
113
- GATE_LIMITS.MAX_CACHE_REUSE_RATIO
114
- ) {
115
- out.push({
116
- severity: "flag",
117
- code: "extreme_cache_ratio",
118
- detail: `cache_read/cache_creation = ${(rt.tokens_cache_read / rt.tokens_cache_creation).toFixed(1)}:1 (real max ~30:1)`,
119
- });
120
- }
121
- if (
122
- rt.tokens_output > 1_000 &&
123
- rt.tokens_cache_creation / rt.tokens_output <
124
- GATE_LIMITS.MIN_CACHE_WRITE_RATIO
125
- ) {
126
- out.push({
127
- severity: "flag",
128
- code: "low_cache_write_ratio",
129
- detail: `cache_creation/output = ${(rt.tokens_cache_creation / rt.tokens_output).toFixed(2)}:1 (real min ~1.5:1)`,
130
- });
131
- }
132
- if (
133
- pillars > 10_000 &&
134
- rt.tokens_input_fresh / pillars < GATE_LIMITS.MIN_INPUT_SHARE_FRAC
135
- ) {
136
- out.push({
137
- severity: "flag",
138
- code: "implausible_input_share",
139
- detail: `input is ${((rt.tokens_input_fresh / pillars) * 100).toFixed(3)}% of total (real min ~0.3%)`,
140
- });
141
- }
142
- if (
143
- rt.active_minutes_est > 0 &&
144
- rt.turns_total / rt.active_minutes_est > GATE_LIMITS.MAX_CADENCE_PER_MIN
145
- ) {
146
- out.push({
147
- severity: "flag",
148
- code: "implausible_cadence",
149
- detail: `${(rt.turns_total / rt.active_minutes_est).toFixed(1)} turns/min (real: 0.5-10)`,
150
- });
151
- }
152
-
153
- return out;
154
- }
155
-
156
- // ── full preflight (plausibility only — NO battery) ─────────────────────────
157
-
158
- /**
159
- * Run preflight plausibility checks against a payload. Returns:
160
- * { pass: true, issues: [] } — clean submission
161
- * { pass: false, issues: [...], wouldDowngrade } — would be flagged/rejected
162
- *
163
- * NOTE: this only mirrors the PUBLIC plausibility gate. The server runs
164
- * additional proprietary checks (the battery) that this preflight does NOT
165
- * replicate. A "pass" here means "passes the plausibility gate," not
166
- * "guaranteed to pass all server gates."
167
- */
168
- export function preflight(payload) {
169
- const issues = plausibilityCheck(payload.raw_telemetry, payload.window);
170
-
171
- const hasReject = issues.some((i) => i.severity === "reject");
172
- const hasFlag = issues.some((i) => i.severity === "flag");
173
-
174
- return {
175
- pass: issues.length === 0,
176
- wouldReject: hasReject,
177
- wouldDowngrade: hasFlag,
178
- issues,
179
- summary: hasReject
180
- ? `REJECT: ${issues
181
- .filter((i) => i.severity === "reject")
182
- .map((i) => i.code)
183
- .join(", ")}`
184
- : hasFlag
185
- ? `FLAG (verified → flagged, not ranked): ${issues
186
- .filter((i) => i.severity === "flag")
187
- .map((i) => i.code)
188
- .join(", ")}`
189
- : "clean — passes plausibility gate (server runs additional proprietary checks)",
190
- };
191
- }
1
+ export * from './submit/preflight.mjs';