@wasit-dev/core 0.6.0 → 0.8.0-beta.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 (68) hide show
  1. package/README.md +12 -4
  2. package/dist/baseline.d.ts +109 -0
  3. package/dist/baseline.js +351 -0
  4. package/dist/catalogue.d.ts +10 -0
  5. package/dist/catalogue.js +69 -3
  6. package/dist/check.d.ts +78 -2
  7. package/dist/check.js +69 -10
  8. package/dist/ci-report.d.ts +74 -0
  9. package/dist/ci-report.js +391 -0
  10. package/dist/config.d.ts +205 -0
  11. package/dist/config.js +1011 -0
  12. package/dist/denied-env.d.ts +33 -0
  13. package/dist/denied-env.js +86 -0
  14. package/dist/errors.d.ts +44 -1
  15. package/dist/errors.js +151 -2
  16. package/dist/guard/budget.d.ts +135 -0
  17. package/dist/guard/budget.js +199 -0
  18. package/dist/guard/ci-event.d.ts +50 -0
  19. package/dist/guard/ci-event.js +125 -0
  20. package/dist/guard/mainnet-optin.d.ts +58 -0
  21. package/dist/guard/mainnet-optin.js +95 -0
  22. package/dist/guard/networks.d.ts +50 -0
  23. package/dist/guard/networks.js +80 -0
  24. package/dist/guard/rpc-identity.d.ts +45 -0
  25. package/dist/guard/rpc-identity.js +156 -0
  26. package/dist/guard/rpc-in-use.d.ts +48 -0
  27. package/dist/guard/rpc-in-use.js +84 -0
  28. package/dist/index.d.ts +34 -3
  29. package/dist/index.js +31 -2
  30. package/dist/mpp/channel-commitment.d.ts +48 -2
  31. package/dist/mpp/channel-commitment.js +80 -4
  32. package/dist/mpp/channel-credential.js +3 -0
  33. package/dist/mpp/channel.js +29 -0
  34. package/dist/mpp/charge.d.ts +25 -2
  35. package/dist/mpp/charge.js +100 -8
  36. package/dist/mpp/network.js +4 -1
  37. package/dist/mpp/suite.js +10 -2
  38. package/dist/report.d.ts +163 -0
  39. package/dist/report.js +282 -0
  40. package/dist/sanitize.d.ts +52 -0
  41. package/dist/sanitize.js +106 -0
  42. package/dist/settlement.d.ts +14 -0
  43. package/dist/settlement.js +1 -1
  44. package/dist/verdict.d.ts +24 -0
  45. package/dist/verdict.js +46 -0
  46. package/dist/versions.d.ts +50 -0
  47. package/dist/versions.js +123 -0
  48. package/dist/x402/chains/evm.d.ts +65 -0
  49. package/dist/x402/chains/evm.js +237 -0
  50. package/dist/x402/chains/index.d.ts +18 -0
  51. package/dist/x402/chains/index.js +28 -0
  52. package/dist/x402/chains/stellar.d.ts +38 -0
  53. package/dist/x402/chains/stellar.js +277 -0
  54. package/dist/x402/chains/svm.d.ts +69 -0
  55. package/dist/x402/chains/svm.js +333 -0
  56. package/dist/x402/chains/types.d.ts +152 -0
  57. package/dist/x402/chains/types.js +10 -0
  58. package/dist/x402/chains/wait.d.ts +36 -0
  59. package/dist/x402/chains/wait.js +42 -0
  60. package/dist/x402/plan.d.ts +82 -0
  61. package/dist/x402/plan.js +146 -0
  62. package/dist/x402/rejected-request.d.ts +146 -0
  63. package/dist/x402/rejected-request.js +269 -0
  64. package/dist/x402/requirements.d.ts +46 -0
  65. package/dist/x402/requirements.js +359 -0
  66. package/dist/x402/simulator.d.ts +74 -17
  67. package/dist/x402/simulator.js +907 -246
  68. package/package.json +11 -6
package/dist/catalogue.js CHANGED
@@ -20,6 +20,7 @@ export const CHECK_CATALOGUE = [
20
20
  protocol: "x402",
21
21
  specRef: "x402 spec, HTTP semantics",
22
22
  summary: "An unpaid request must be answered with status code 402.",
23
+ fix: "Answer an unpaid request with 402 Payment Required and the challenge in a PAYMENT-REQUIRED header. A 200 means the route serves without payment; a 404 often means the wrong path or method (try --method POST).",
23
24
  },
24
25
  {
25
26
  id: "X402-02",
@@ -27,6 +28,7 @@ export const CHECK_CATALOGUE = [
27
28
  protocol: "x402",
28
29
  specRef: "x402 built-on-stellar guide",
29
30
  summary: "The 402 response must include a payment header.",
31
+ fix: "Send the challenge as base64-encoded JSON in a PAYMENT-REQUIRED response header, as the x402 v2 HTTP transport defines.",
30
32
  },
31
33
  {
32
34
  id: "X402-03",
@@ -34,20 +36,23 @@ export const CHECK_CATALOGUE = [
34
36
  protocol: "x402",
35
37
  specRef: "x402 spec §payment-required-object",
36
38
  summary: "The header value must be valid base64 that decodes to JSON.",
39
+ fix: "Base64-encode the JSON PaymentRequired object for the PAYMENT-REQUIRED header; the value must decode to valid JSON.",
37
40
  },
38
41
  {
39
42
  id: "X402-04",
40
43
  name: "Required Fields Present",
41
44
  protocol: "x402",
42
45
  specRef: "x402 spec §payment-required-object",
43
- summary: "The payload must include the core payment terms, under the field names its advertised version requires.",
46
+ summary: "Every payment option must carry each field its advertised version requires, with the right types.",
47
+ fix: "Give every option in `accepts` the fields its x402Version requires (v2: scheme, network, amount, asset, payTo, maxTimeoutSeconds).",
44
48
  },
45
49
  {
46
50
  id: "X402-05",
47
51
  name: "Network Identifier Valid",
48
52
  protocol: "x402",
49
- specRef: "x402 built-on-stellar guide",
50
- summary: "The network identifier must follow CAIP-2 (stellar:testnet or stellar:pubnet).",
53
+ specRef: "x402 v2 spec §11.1; CAIP-2",
54
+ summary: "Every advertised network identifier must be CAIP-2, and follow its namespace's rules where Wasit knows them (stellar, eip155, solana).",
55
+ fix: "Name each network with its CAIP-2 id, such as stellar:testnet or eip155:84532.",
51
56
  },
52
57
  {
53
58
  id: "X402-06",
@@ -56,6 +61,7 @@ export const CHECK_CATALOGUE = [
56
61
  specRef: "x402 spec §payment-flow",
57
62
  summary: "A resubmitted request carrying a valid signature must be accepted.",
58
63
  costsFunds: true,
64
+ fix: "After a valid payment, settle it, serve the resource with a 2xx, and return a PAYMENT-RESPONSE header naming the transaction that moved exactly the advertised amount of the asset to payTo.",
59
65
  },
60
66
  {
61
67
  id: "X402-07",
@@ -65,6 +71,45 @@ export const CHECK_CATALOGUE = [
65
71
  summary: "A deliberately corrupted signature must be rejected, not accepted.",
66
72
  negative: true,
67
73
  costsFunds: true,
74
+ fix: "Verify every payment before serving: pass it to the facilitator's verify step and refuse it when verification fails. Never serve on a payload that was only decoded.",
75
+ },
76
+ {
77
+ id: "X402-08",
78
+ name: "Payment Replay Rejected",
79
+ protocol: "x402",
80
+ specRef: "x402 v2 spec §10.1 (replay protection); exact scheme, one-time use",
81
+ summary: "A payment that was already accepted must not be accepted again.",
82
+ negative: true,
83
+ fix: "Treat every payment as single-use: verify it with the facilitator before serving, which refuses an authorization whose nonce is already spent, and never serve the same payload twice.",
84
+ },
85
+ {
86
+ id: "X402-09",
87
+ name: "Underpayment Rejected",
88
+ protocol: "x402",
89
+ specRef: "exact scheme verification: amount (Stellar: exactly requirements.amount; EVM: step 3)",
90
+ summary: "A validly signed payment for less than the advertised amount must be rejected.",
91
+ negative: true,
92
+ costsFunds: true,
93
+ fix: "Hold the signed payment to the advertised amount before serving. The facilitator's verify does; a server that skips it, or checks only the signature, sells for less than its price.",
94
+ },
95
+ {
96
+ id: "X402-10",
97
+ name: "Expired Authorization Rejected",
98
+ protocol: "x402",
99
+ specRef: "x402 v2 spec §10.1 (time constraints); exact scheme verification: validity window",
100
+ summary: "A payment whose authorization has expired must be rejected.",
101
+ negative: true,
102
+ fix: "Verify each payment with the facilitator before serving: it refuses an authorization past its window (validBefore on EVM, the auth entry's expiration ledger on Stellar).",
103
+ },
104
+ {
105
+ id: "X402-11",
106
+ name: "Rejected Request Not Settled",
107
+ protocol: "x402",
108
+ specRef: "x402 v2 spec §6.1 (verify, run the resource, settle); Soroban authorization nonces",
109
+ summary: "A valid payment sent with a request the config declares invalid must not settle: the chain still holds its authorization unused after it expires.",
110
+ negative: true,
111
+ costsFunds: true,
112
+ fix: "Validate a request before its payment is settled, and settle only once the request has been accepted; a refused request must not cost the payer.",
68
113
  },
69
114
  {
70
115
  id: "MPP-01",
@@ -73,6 +118,7 @@ export const CHECK_CATALOGUE = [
73
118
  specRef: "MPP Charge Guide; CAP-46 transfer events",
74
119
  summary: "The charge settles on-chain for exactly what the target advertised.",
75
120
  costsFunds: true,
121
+ fix: "Settle each charge on-chain for exactly the advertised amount, currency and recipient, from the paying account, and reference that transaction in the Payment-Receipt header.",
76
122
  },
77
123
  {
78
124
  id: "MPP-10",
@@ -80,6 +126,7 @@ export const CHECK_CATALOGUE = [
80
126
  protocol: "mpp-channel",
81
127
  specRef: "MPP Channel Guide",
82
128
  summary: "The channel contract deploys correctly and is the same channel the target bills through.",
129
+ fix: "Bill through the channel advertised in the 402 challenge, opened with the token, funder, recipient and refund waiting period you expect.",
83
130
  },
84
131
  {
85
132
  id: "MPP-11",
@@ -87,6 +134,7 @@ export const CHECK_CATALOGUE = [
87
134
  protocol: "mpp-channel",
88
135
  specRef: "MPP Channel Guide §closing-the-channel; @stellar/mpp channel server",
89
136
  summary: "A commitment must exceed the stored cumulative and cover the price of the current request.",
137
+ fix: "Refuse with 402 any commitment that does not exceed the stored cumulative amount, or that does not cover the price of the current request.",
90
138
  },
91
139
  {
92
140
  id: "MPP-12",
@@ -95,6 +143,7 @@ export const CHECK_CATALOGUE = [
95
143
  specRef: "MPP Channel Guide §closing-the-channel; @stellar/mpp channel server",
96
144
  summary: "A byte-identical credential resubmitted against the same challenge must be rejected.",
97
145
  negative: true,
146
+ fix: "Record each challenge id when a credential for it is accepted, and refuse a second credential for the same challenge with 402.",
98
147
  },
99
148
  {
100
149
  id: "MPP-13",
@@ -104,6 +153,7 @@ export const CHECK_CATALOGUE = [
104
153
  summary: "Closing with the highest commitment settles on-chain. Permanently ends the channel.",
105
154
  destructive: true,
106
155
  costsFunds: true,
156
+ fix: "On close, settle the highest commitment on-chain: `withdrawn` must equal the committed amount and `closeEffectiveAtLedger` must be set.",
107
157
  },
108
158
  {
109
159
  id: "MPP-14",
@@ -112,5 +162,21 @@ export const CHECK_CATALOGUE = [
112
162
  specRef: "MPP Channel Guide §closing-the-channel; @stellar/mpp channel server",
113
163
  summary: "A captured (amount, signature) pair must not be redeemable against a new challenge.",
114
164
  negative: true,
165
+ fix: "Refuse with 402 a previously accepted commitment presented under a new challenge: the cumulative amount must strictly increase.",
115
166
  },
116
167
  ];
168
+ /** Where each protocol's checks are documented on the site. */
169
+ const DOCS_URLS = {
170
+ x402: "https://usewasit.dev/docs/checks/x402",
171
+ "mpp-charge": "https://usewasit.dev/docs/checks/mpp-charge-mode",
172
+ "mpp-channel": "https://usewasit.dev/docs/checks/mpp-channel-mode",
173
+ };
174
+ /** The catalogue entry for a check id, if there is one (PREFLIGHT has none). */
175
+ export function catalogueEntry(id) {
176
+ return CHECK_CATALOGUE.find((entry) => entry.id === id);
177
+ }
178
+ /** The docs page for a check id, if it is in the catalogue. */
179
+ export function docsUrlFor(id) {
180
+ const entry = catalogueEntry(id);
181
+ return entry === undefined ? undefined : DOCS_URLS[entry.protocol];
182
+ }
package/dist/check.d.ts CHANGED
@@ -2,6 +2,22 @@
2
2
  * The result shape shared by every conformance check, across protocols.
3
3
  */
4
4
  import { type CheckError } from "./errors.js";
5
+ /**
6
+ * Why a check did not run, for a reader who has to tell "Wasit cannot grade
7
+ * this" from "you asked for less" from "an earlier check failed". The four
8
+ * statuses stay as they are; this refines SKIP and nothing else.
9
+ *
10
+ * - `unsupported`: Wasit cannot grade it (an x402 v1 challenge, a network it
11
+ * does not pay on). Not a FAIL, and not a pass either.
12
+ * - `resource-consumed`: the first payment used up a single-use resource.
13
+ * - `needs-payer`: the check pays and no payer key was given.
14
+ * - `read-only`: the run was asked not to pay.
15
+ * - `not-applicable`: the target gives the check nothing to test.
16
+ * - `dependency`: an earlier check failed or gave no verdict, so there is
17
+ * nothing for this one to inspect.
18
+ */
19
+ export type SkipKind = "unsupported" | "resource-consumed" | "needs-payer" | "read-only" | "not-applicable" | "dependency";
20
+ export declare const SKIP_KINDS: readonly SkipKind[];
5
21
  export interface CheckResult {
6
22
  /** Stable catalogue identifier, e.g. "MPP-11". Must match docs/CHECKS.md. */
7
23
  id: string;
@@ -9,6 +25,29 @@ export interface CheckResult {
9
25
  /** False when the check ran and the target did not conform. */
10
26
  pass: boolean;
11
27
  detail: string;
28
+ /**
29
+ * What to change, for the specific cause this failure found. Optional:
30
+ * a failure without one falls back to its catalogue entry's `fix` (see
31
+ * {@link fixFor}). Meaningful only on a FAIL.
32
+ */
33
+ hint?: string;
34
+ /**
35
+ * What the check expected, and what the service sent instead, in a few words
36
+ * each ("status 402", "status 200"). Set by the check that knows them, on a
37
+ * FAIL, so a report can show the reason, the expected and the actual value,
38
+ * and the fix. `detail` and `hint` say the same in prose and are unchanged.
39
+ * Both quote the service, so both pass through the sanitiser on the way out,
40
+ * and are cut to a short length there, after the secrets are removed.
41
+ */
42
+ expected?: string;
43
+ actual?: string;
44
+ /**
45
+ * The settlement a check read back from the chain and found to be this
46
+ * payment (X402-06's transaction: a Stellar or EVM transaction hash, a Solana
47
+ * signature). Set only on a PASS whose settlement was verified on chain; a
48
+ * report may link it to an explorer after checking its shape.
49
+ */
50
+ reference?: string;
12
51
  /**
13
52
  * True when the check did not run. A skipped check is neither a pass nor a
14
53
  * failure: `pass` is false so it can never be counted as conformance, and
@@ -17,6 +56,8 @@ export interface CheckResult {
17
56
  skipped?: boolean;
18
57
  /** Why the check was skipped. Required whenever `skipped` is true. */
19
58
  skipReason?: string;
59
+ /** What kind of reason it is, when the code that skipped it knows. Meaningful only on a SKIP. */
60
+ skipKind?: SkipKind;
20
61
  /**
21
62
  * True when running this check permanently alters the target's state.
22
63
  * Destructive checks are skipped unless the operator explicitly opts in,
@@ -66,8 +107,31 @@ export declare function skippedDestructive(id: string, name: string, reason: str
66
107
  * reported and exit-coded separately from conformance failures.
67
108
  */
68
109
  export declare function errored(id: string, name: string, error: unknown): CheckResult;
69
- /** Builds the result for a check that was not run, for a non-destructive reason. */
70
- export declare function skipped(id: string, name: string, reason: string): CheckResult;
110
+ /**
111
+ * Builds the result for a check that was not run, for a non-destructive reason.
112
+ * `kind` says what sort of reason it is; leave it out when the code does not know.
113
+ */
114
+ export declare function skipped(id: string, name: string, reason: string, kind?: SkipKind): CheckResult;
115
+ /**
116
+ * A value a service sent, quoted for the `actual` of a FAIL: a string in JSON
117
+ * quotes (control characters written out, not carried), anything else as JSON.
118
+ *
119
+ * Not cut here unless `max` is given. A cut made before the secrets of the run
120
+ * are removed can leave the start of a secret in the output, so the cut is made
121
+ * by the sinks that remove them (`redactValue`, the comment renderer).
122
+ */
123
+ export declare function quoteValue(value: unknown, max?: number): string;
124
+ /** What to do about a failure, and where it is documented. */
125
+ export interface FailureGuidance {
126
+ readonly fix: string;
127
+ readonly docs?: string;
128
+ }
129
+ /**
130
+ * The guidance a front end shows under a FAIL: the result's own hint when it
131
+ * has one, else the check's catalogue fix. Undefined for anything that is not
132
+ * a FAIL, so a pass, a skip or a no-verdict never reads as a defect to fix.
133
+ */
134
+ export declare function fixFor(result: CheckResult): FailureGuidance | undefined;
71
135
  /** One check's result, reshaped for a machine-readable front end (CLI --json, MCP). */
72
136
  export interface StructuredCheckResult {
73
137
  readonly id: string;
@@ -80,6 +144,18 @@ export interface StructuredCheckResult {
80
144
  * unreachable | configuration | harness | setup.
81
145
  */
82
146
  readonly errorKind?: string;
147
+ /** Present only when `status` is "SKIP" and the reason has a kind: see {@link SkipKind}. */
148
+ readonly skipKind?: SkipKind;
149
+ /** Present only when `status` is "FAIL" and the check recorded it: what it expected. */
150
+ readonly expected?: string;
151
+ /** Present only when `status` is "FAIL" and the check recorded it: what the service sent. */
152
+ readonly actual?: string;
153
+ /** Present only when `status` is "PASS" and the check verified a settlement on chain: its reference. */
154
+ readonly reference?: string;
155
+ /** Present only when `status` is "FAIL": what to change (see {@link fixFor}). */
156
+ readonly fix?: string;
157
+ /** Present only when `status` is "FAIL": the check's docs page. */
158
+ readonly docs?: string;
83
159
  }
84
160
  /** A full run, reshaped for a machine-readable front end (CLI --json, MCP). */
85
161
  export interface StructuredRun {
package/dist/check.js CHANGED
@@ -1,7 +1,17 @@
1
1
  /**
2
2
  * The result shape shared by every conformance check, across protocols.
3
3
  */
4
+ import { catalogueEntry, docsUrlFor } from "./catalogue.js";
4
5
  import { classifyCheckError } from "./errors.js";
6
+ import { sanitizeText } from "./sanitize.js";
7
+ export const SKIP_KINDS = [
8
+ "unsupported",
9
+ "resource-consumed",
10
+ "needs-payer",
11
+ "read-only",
12
+ "not-applicable",
13
+ "dependency",
14
+ ];
5
15
  /**
6
16
  * Classifies one result.
7
17
  *
@@ -83,17 +93,50 @@ export function errored(id, name, error) {
83
93
  detail: `Check could not run (${classified.kind}): ${classified.message}`,
84
94
  };
85
95
  }
86
- /** Builds the result for a check that was not run, for a non-destructive reason. */
87
- export function skipped(id, name, reason) {
96
+ /**
97
+ * Builds the result for a check that was not run, for a non-destructive reason.
98
+ * `kind` says what sort of reason it is; leave it out when the code does not know.
99
+ */
100
+ export function skipped(id, name, reason, kind) {
88
101
  return {
89
102
  id,
90
103
  name,
91
104
  pass: false,
92
105
  skipped: true,
93
106
  skipReason: reason,
107
+ ...(kind === undefined ? {} : { skipKind: kind }),
94
108
  detail: `Skipped: ${reason}`,
95
109
  };
96
110
  }
111
+ /**
112
+ * A value a service sent, quoted for the `actual` of a FAIL: a string in JSON
113
+ * quotes (control characters written out, not carried), anything else as JSON.
114
+ *
115
+ * Not cut here unless `max` is given. A cut made before the secrets of the run
116
+ * are removed can leave the start of a secret in the output, so the cut is made
117
+ * by the sinks that remove them (`redactValue`, the comment renderer).
118
+ */
119
+ export function quoteValue(value, max) {
120
+ const quoted = typeof value === "string" ? JSON.stringify(value) : (JSON.stringify(value) ?? String(value));
121
+ if (max === undefined)
122
+ return quoted;
123
+ const characters = Array.from(quoted);
124
+ return characters.length <= max ? quoted : `${characters.slice(0, Math.max(1, max - 1)).join("")}…`;
125
+ }
126
+ /**
127
+ * The guidance a front end shows under a FAIL: the result's own hint when it
128
+ * has one, else the check's catalogue fix. Undefined for anything that is not
129
+ * a FAIL, so a pass, a skip or a no-verdict never reads as a defect to fix.
130
+ */
131
+ export function fixFor(result) {
132
+ if (checkStatus(result) !== "FAIL")
133
+ return undefined;
134
+ const fix = result.hint ?? catalogueEntry(result.id)?.fix;
135
+ if (fix === undefined)
136
+ return undefined;
137
+ const docs = docsUrlFor(result.id);
138
+ return docs === undefined ? { fix } : { fix, docs };
139
+ }
97
140
  /**
98
141
  * Reshapes a run into the one JSON shape every machine-readable front end
99
142
  * uses — the CLI's `--json` output and the MCP server's `structuredContent`
@@ -113,13 +156,29 @@ export function toStructuredRun(results) {
113
156
  failed: counts.failed,
114
157
  errored: counts.errored,
115
158
  skipped: counts.skipped,
116
- results: results.map((result) => ({
117
- id: result.id,
118
- name: result.name,
119
- status: checkStatus(result),
120
- detail: result.detail,
121
- destructive: result.destructive === true,
122
- ...(result.error ? { errorKind: result.error.kind } : {}),
123
- })),
159
+ results: results.map((result) => {
160
+ const guidance = fixFor(result);
161
+ const status = checkStatus(result);
162
+ return {
163
+ id: result.id,
164
+ // Text a service chose can reach these three fields; the report is a
165
+ // sink for the one sanitiser (spec A8 #6).
166
+ name: sanitizeText(result.name),
167
+ status,
168
+ detail: sanitizeText(result.detail),
169
+ destructive: result.destructive === true,
170
+ ...(result.error ? { errorKind: result.error.kind } : {}),
171
+ ...(status === "SKIP" && result.skipKind !== undefined ? { skipKind: result.skipKind } : {}),
172
+ ...(status === "FAIL" && result.expected !== undefined ? { expected: sanitizeText(result.expected) } : {}),
173
+ ...(status === "FAIL" && result.actual !== undefined ? { actual: sanitizeText(result.actual) } : {}),
174
+ ...(status === "PASS" && result.reference !== undefined ? { reference: sanitizeText(result.reference) } : {}),
175
+ ...(guidance === undefined
176
+ ? {}
177
+ : {
178
+ fix: sanitizeText(guidance.fix),
179
+ ...(guidance.docs === undefined ? {} : { docs: guidance.docs }),
180
+ }),
181
+ };
182
+ }),
124
183
  };
125
184
  }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The pull request comment and the job summary (spec A4, A5), as pure
3
+ * functions over the run report and, when there is one, the baseline of the
4
+ * default branch.
5
+ *
6
+ * Every value that can carry text a service chose goes through
7
+ * `sanitizeForMarkdown`: one line, links and mentions removed, 300 characters at
8
+ * most, Markdown and HTML escaped. What is not passed through it is a constant
9
+ * of this file, a number, or a value checked against a fixed set (an outcome, a
10
+ * status, a protocol, a version, a docs link on usewasit.dev).
11
+ */
12
+ import { type Baseline, type History } from "./baseline.js";
13
+ import { type RunReport } from "./report.js";
14
+ import { type ToolVersions } from "./versions.js";
15
+ /** The comment that starts with this is the one Wasit updates. */
16
+ export declare const COMMENT_MARKER = "<!-- wasit-report -->";
17
+ export interface CiReportInput {
18
+ readonly report: RunReport;
19
+ /** The baseline of the default branch, when one was found and could be read. */
20
+ readonly baseline?: Baseline;
21
+ /** Why no baseline could be used, when one was looked for: shown in place of "no baseline yet". */
22
+ readonly baselineNote?: string;
23
+ /** The id of the run on main the baseline came from: the last green one (D-022b). */
24
+ readonly baselineRun?: number;
25
+ /**
26
+ * The history of every completed run on main, failed ones included (D-022b),
27
+ * for the recent-failures line. Absent: the baseline's own history.
28
+ */
29
+ readonly history?: History;
30
+ /** Values no output may carry (a header value, a key, an RPC url). */
31
+ readonly secrets?: readonly string[];
32
+ }
33
+ /** The pull request comment: the marker, then the report. */
34
+ export declare function renderComment(input: CiReportInput): string;
35
+ /** The job summary: the same text without the marker. */
36
+ export declare function renderSummary(input: CiReportInput): string;
37
+ /** The pull request comment for a run that left no report: the marker, then the fixed text. */
38
+ export declare function renderNoReportComment(versions: ToolVersions): string;
39
+ /** The job summary for a run that left no report: the same text without the marker. */
40
+ export declare function renderNoReportSummary(versions: ToolVersions): string;
41
+ /** What a GitHub check run shows: its title, its summary and how it ended. */
42
+ export interface CheckRunOutput {
43
+ /** At most 255 characters: the verdict and the counts, nothing a service chose. */
44
+ readonly title: string;
45
+ /** The job summary's text: the same sanitised report. */
46
+ readonly summary: string;
47
+ readonly conclusion: "success" | "failure" | "neutral";
48
+ }
49
+ /**
50
+ * The check run "Wasit conformance" at the end of a run: success for a run that
51
+ * exits 0, failure for 1, neutral for no verdict. The title holds only the
52
+ * verdict word and counts; the summary is the job summary.
53
+ */
54
+ export declare function renderCheckRun(input: CiReportInput): CheckRunOutput;
55
+ /** The check run for a run that left no report: neutral, with the fixed text of the no-report comment. */
56
+ export declare function renderNoReportCheckRun(versions: ToolVersions): CheckRunOutput;
57
+ export interface RunningCommentInput {
58
+ /** When the run started, as an ISO time; anything else is left out. */
59
+ readonly startedAt: string;
60
+ /** The run's page; left out unless it has the shape GitHub gives it. */
61
+ readonly runUrl?: string;
62
+ /** The environment the run tests, when the workflow names one. */
63
+ readonly environment?: string;
64
+ /** Values no output may carry. */
65
+ readonly secrets?: readonly string[];
66
+ }
67
+ /**
68
+ * The pull request comment while Wasit runs (Najmi, 2026-11-20): the marker,
69
+ * then a fixed line with the start time and a link to the run. The result
70
+ * replaces it when the run ends. The only value from outside is the
71
+ * environment's name, which goes through the sanitiser; the link is used only
72
+ * when it has the shape of a GitHub run page.
73
+ */
74
+ export declare function renderRunningComment(input: RunningCommentInput): string;