@perpscope/percolator-adapter 0.7.0 → 0.8.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/README.md CHANGED
@@ -63,6 +63,8 @@ The full field-level contract is documented in `../../docs/field-compatibility-m
63
63
 
64
64
  `compareCompatibilityReports(previous, current)` returns `perpscope.compatibility-diff` with score delta, status change, new/resolved fields, section drift, and merged alias suggestions.
65
65
 
66
+ `buildCompatibilityRealityCheck(report, { input })` returns `perpscope.reality-check` with provenance, required/useful mapped counts, unknown fields, and alias counts. Use it when a terminal needs to show whether a capture is synthetic, real-backed candidate, or externally submitted.
67
+
66
68
  ## CLI
67
69
 
68
70
  ```bash
@@ -76,6 +78,8 @@ Try it locally with:
76
78
  perpscope compat diff ../../examples/fixture-pack-minimal-terminal.json ../../examples/fixture-pack-drifted-aliases.json
77
79
  ```
78
80
 
81
+ For the real-backed candidate path, try `../../examples/fixture-pack-real-sanitized-rpc-shape.json`.
82
+
79
83
  ## DTO Example
80
84
 
81
85
  ```js
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export {
2
2
  assertReadOnlySnapshot,
3
+ buildCompatibilityRealityCheck,
3
4
  buildPercolatorCompatibilityReport,
4
5
  compareCompatibilityReports,
5
6
  detectPercolatorInputShape,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perpscope/percolator-adapter",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "Read-only Percolator adapter helpers for Solana perps terminals.",
6
6
  "main": "./index.js",
@@ -1,6 +1,6 @@
1
1
  import { normalizeFundingSkewHistory } from "./funding-history.js";
2
2
 
3
- export const PERPSCOPE_ADAPTER_VERSION = "0.7.0";
3
+ export const PERPSCOPE_ADAPTER_VERSION = "0.8.0";
4
4
 
5
5
  const KEYPAIR_FIELD_PATTERN = /(^|_)(secret|private|keypair|mnemonic|seed|walletPath|wallet)(_|$)/i;
6
6
  const HISTORY_COMMAND_KEYS = new Set([
@@ -231,6 +231,60 @@ export function exportCompatibilityReportFromReport(report, options = {}) {
231
231
  };
232
232
  }
233
233
 
234
+ export function buildCompatibilityRealityCheck(inputOrReport, options = {}) {
235
+ const hasReportShape = inputOrReport && typeof inputOrReport === "object" && Array.isArray(inputOrReport.recognizedSections);
236
+ const input = hasReportShape ? options.input : inputOrReport;
237
+ const report = hasReportShape ? normalizeCompatibilityReport(inputOrReport) : buildPercolatorCompatibilityReport(inputOrReport);
238
+ const requiredFields = COMPATIBILITY_FIELD_SPECS.filter((field) => field.severity === "danger");
239
+ const optionalFields = COMPATIBILITY_FIELD_SPECS.filter((field) => field.severity !== "danger");
240
+ const missingFieldSet = new Set((report.missingFields || []).map((field) => field.field));
241
+ const mappedRequired = requiredFields.filter((field) => !missingFieldSet.has(field.field));
242
+ const mappedOptional = optionalFields.filter((field) => !missingFieldSet.has(field.field));
243
+ const provenance = realityProvenance(input, report);
244
+ const unknownCount = report.summary?.ignoredCount ?? report.ignoredFields.length;
245
+ const aliasCount = report.summary?.suggestionCount ?? report.aliasSuggestions.length;
246
+ const dangerMissing = (report.missingFields || []).filter((field) => field.severity === "danger").length;
247
+ const warningMissing = (report.missingFields || []).length - dangerMissing;
248
+ const tone = dangerMissing
249
+ ? "danger"
250
+ : warningMissing || unknownCount || provenance.status === "candidate"
251
+ ? "warning"
252
+ : "good";
253
+
254
+ return {
255
+ schema: "perpscope.reality-check",
256
+ version: 1,
257
+ package: {
258
+ name: "@perpscope/percolator-adapter",
259
+ version: options.packageVersion || PERPSCOPE_ADAPTER_VERSION
260
+ },
261
+ generatedAt: options.generatedAt || new Date().toISOString(),
262
+ tone,
263
+ status: provenance.status,
264
+ sourceKind: provenance.kind,
265
+ provenance,
266
+ mapped: {
267
+ requiredCount: mappedRequired.length,
268
+ requiredTotal: requiredFields.length,
269
+ optionalCount: mappedOptional.length,
270
+ optionalTotal: optionalFields.length,
271
+ recognizedCount: report.summary?.recognizedCount ?? report.recognizedSections.length
272
+ },
273
+ gaps: {
274
+ dangerMissing,
275
+ warningMissing,
276
+ unknownCount,
277
+ aliasCount
278
+ },
279
+ lanes: [
280
+ realityLane("required", `${mappedRequired.length}/${requiredFields.length}`, dangerMissing ? "danger" : "good"),
281
+ realityLane("useful", `${mappedOptional.length}/${optionalFields.length}`, warningMissing ? "warning" : "good"),
282
+ realityLane("unknown", String(unknownCount), unknownCount ? "warning" : "good"),
283
+ realityLane("aliases", String(aliasCount), aliasCount ? "good" : "neutral")
284
+ ]
285
+ };
286
+ }
287
+
234
288
  const COMPATIBILITY_SECTION_SPECS = [
235
289
  {
236
290
  id: "safety",
@@ -659,6 +713,30 @@ function compatibilityDiffSummary(report) {
659
713
  };
660
714
  }
661
715
 
716
+ function realityLane(label, value, tone = "neutral") {
717
+ return { label, value, tone };
718
+ }
719
+
720
+ function realityProvenance(input, report) {
721
+ const source = report.source || {};
722
+ const inputSource = input && typeof input === "object" && !Array.isArray(input) ? input.source || {} : {};
723
+ const kind = stringOf(input, ["fixtureKind", "sourceKind"], inputSource.kind || source.shape || report.shape || "decoded-capture");
724
+ const candidate = /candidate|read-only-rpc|real/i.test(kind) || Boolean(inputSource.realBacked);
725
+ const submitted = Boolean(inputSource.submittedBy) || Boolean(inputSource.externalSubmission);
726
+ const status = submitted ? "submitted" : candidate ? "candidate" : "synthetic";
727
+ return {
728
+ status,
729
+ kind,
730
+ label: source.label || stringOf(input, ["label"], "decoded capture"),
731
+ cluster: source.cluster || stringOf(input, ["cluster"], "unknown"),
732
+ basis: inputSource.basis || inputSource.capture || "",
733
+ fixture: stringOf(input, ["fixture"], ""),
734
+ sanitized: inputSource.sanitized !== false,
735
+ submittedBy: inputSource.submittedBy || "",
736
+ note: inputSource.note || (status === "candidate" ? "real-backed candidate; still waiting on third-party decoded shape" : "")
737
+ };
738
+ }
739
+
662
740
  function differenceByField(left = [], right = []) {
663
741
  const rightFields = new Set((right || []).map((entry) => entry.field));
664
742
  return (left || []).filter((entry) => !rightFields.has(entry.field));
@@ -97,6 +97,10 @@ export function buildReadOnlyRpcSnapshot(request) {
97
97
  if (decoded.params) commands.push({ command: "slab:params", output: decoded.params });
98
98
  if (decoded.engine) commands.push({ command: "slab:engine", output: decoded.engine });
99
99
  if (decoded.bestPrice) commands.push({ command: "best-price", output: decoded.bestPrice });
100
+ if (decoded.receipts || decoded.executionReceipts) commands.push({ command: "execution:receipts", output: decoded.receipts || decoded.executionReceipts });
101
+ if (decoded.fundingSkew || decoded.fundingHistory || decoded.fundingSkewHistory) {
102
+ commands.push({ command: "funding-skew-history", output: decoded.fundingSkew || decoded.fundingHistory || decoded.fundingSkewHistory });
103
+ }
100
104
  if (decoded.accounts) commands.push({ command: "slab:accounts", output: decoded.accounts });
101
105
  if (decoded.bitmap) commands.push({ command: "slab:bitmap", output: decoded.bitmap });
102
106