@senpi/runtime 3.0.55 → 3.0.57
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/dist/cli/senpi-commands.d.ts.map +1 -1
- package/dist/cli/senpi-commands.js +2 -0
- package/dist/cli/senpi-commands.js.map +1 -1
- package/dist/cli/validate-command.d.ts +29 -0
- package/dist/cli/validate-command.d.ts.map +1 -0
- package/dist/cli/validate-command.js +89 -0
- package/dist/cli/validate-command.js.map +1 -0
- package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
- package/dist/dsl/monitor/process-one-position.js +5 -1
- package/dist/dsl/monitor/process-one-position.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/load-runtime-config.d.ts +38 -0
- package/dist/runtime/load-runtime-config.d.ts.map +1 -1
- package/dist/runtime/load-runtime-config.js +33 -25
- package/dist/runtime/load-runtime-config.js.map +1 -1
- package/dist/runtime/runtime-schema.d.ts +100 -100
- package/dist/scanners/external/scaffold/__main__.py +8 -0
- package/dist/scanners/external/scaffold/ctx.py +15 -1
- package/dist/scanners/external/scaffold/http_post.py +22 -0
- package/dist/scanners/external/scaffold/import_check.py +305 -0
- package/dist/scanners/external/scaffold/preflight.py +541 -0
- package/dist/scanners/external/scaffold/scaffold.py +11 -2
- package/dist/scanners/implementations/market-regime.d.ts +1 -1
- package/dist/telemetry/metrics.d.ts +6 -0
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +45 -0
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/utils/event-catalog.d.ts +22 -0
- package/dist/utils/event-catalog.d.ts.map +1 -1
- package/dist/utils/event-catalog.js +6 -0
- package/dist/utils/event-catalog.js.map +1 -1
- package/dist/validate/codes.d.ts +163 -0
- package/dist/validate/codes.d.ts.map +1 -0
- package/dist/validate/codes.js +375 -0
- package/dist/validate/codes.js.map +1 -0
- package/dist/validate/coverage.d.ts +34 -0
- package/dist/validate/coverage.d.ts.map +1 -0
- package/dist/validate/coverage.js +34 -0
- package/dist/validate/coverage.js.map +1 -0
- package/dist/validate/import-stage.d.ts +56 -0
- package/dist/validate/import-stage.d.ts.map +1 -0
- package/dist/validate/import-stage.js +238 -0
- package/dist/validate/import-stage.js.map +1 -0
- package/dist/validate/index.d.ts +28 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +27 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/install-gate.d.ts +44 -0
- package/dist/validate/install-gate.d.ts.map +1 -0
- package/dist/validate/install-gate.js +66 -0
- package/dist/validate/install-gate.js.map +1 -0
- package/dist/validate/live-stage.d.ts +108 -0
- package/dist/validate/live-stage.d.ts.map +1 -0
- package/dist/validate/live-stage.js +416 -0
- package/dist/validate/live-stage.js.map +1 -0
- package/dist/validate/proof.d.ts +104 -0
- package/dist/validate/proof.d.ts.map +1 -0
- package/dist/validate/proof.js +256 -0
- package/dist/validate/proof.js.map +1 -0
- package/dist/validate/recipe-checks.d.ts +79 -0
- package/dist/validate/recipe-checks.d.ts.map +1 -0
- package/dist/validate/recipe-checks.js +202 -0
- package/dist/validate/recipe-checks.js.map +1 -0
- package/dist/validate/recipe.d.ts +41 -0
- package/dist/validate/recipe.d.ts.map +1 -0
- package/dist/validate/recipe.js +215 -0
- package/dist/validate/recipe.js.map +1 -0
- package/dist/validate/report.d.ts +35 -0
- package/dist/validate/report.d.ts.map +1 -0
- package/dist/validate/report.js +78 -0
- package/dist/validate/report.js.map +1 -0
- package/dist/validate/run.d.ts +101 -0
- package/dist/validate/run.d.ts.map +1 -0
- package/dist/validate/run.js +444 -0
- package/dist/validate/run.js.map +1 -0
- package/dist/validate/signal-stage.d.ts +40 -0
- package/dist/validate/signal-stage.d.ts.map +1 -0
- package/dist/validate/signal-stage.js +116 -0
- package/dist/validate/signal-stage.js.map +1 -0
- package/dist/validate/target.d.ts +70 -0
- package/dist/validate/target.d.ts.map +1 -0
- package/dist/validate/target.js +231 -0
- package/dist/validate/target.js.map +1 -0
- package/dist/validate/telemetry.d.ts +24 -0
- package/dist/validate/telemetry.d.ts.map +1 -0
- package/dist/validate/telemetry.js +60 -0
- package/dist/validate/telemetry.js.map +1 -0
- package/dist/validate/types.d.ts +115 -0
- package/dist/validate/types.d.ts.map +1 -0
- package/dist/validate/types.js +31 -0
- package/dist/validate/types.js.map +1 -0
- package/dist/validate/wallet.d.ts +63 -0
- package/dist/validate/wallet.d.ts.map +1 -0
- package/dist/validate/wallet.js +66 -0
- package/dist/validate/wallet.js.map +1 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The closed set of `senpi validate` finding codes, and their metadata.
|
|
3
|
+
*
|
|
4
|
+
* Same shape as `utils/event-catalog.ts`'s `SENPI_ERROR_CODE`: a const map for call sites plus a
|
|
5
|
+
* companion record for per-code data. Two structures rather than one because the map gives call
|
|
6
|
+
* sites `VALIDATE_CODE.scanMissing` instead of a bare string literal, and the record is a
|
|
7
|
+
* `Record<ValidateCode, …>` so the compiler — not a test — enforces that every code has metadata.
|
|
8
|
+
*
|
|
9
|
+
* ## Why these do not reuse the supervision codes
|
|
10
|
+
*
|
|
11
|
+
* `SENPI_ERROR_CODE` already carries `E_SCANNER_TICK_ERROR` / `E_SCANNER_TICK_TIMEOUT`, and some
|
|
12
|
+
* conditions here are the same *condition*. They are deliberately NOT reused. A validation finding
|
|
13
|
+
* is an authoring-time observation; a supervision code is a production event on a running
|
|
14
|
+
* strategy. Sharing identifiers would make authoring noise indistinguishable from production
|
|
15
|
+
* failure the moment anything starts consuming either — dashboards, alerts, or the telemetry that
|
|
16
|
+
* exists to show which mistakes agents actually make.
|
|
17
|
+
*
|
|
18
|
+
* ## Severity lives in the prefix
|
|
19
|
+
*
|
|
20
|
+
* `E_` fails the run; `W_` is reported and only fails under `--strict`. Severity is DERIVED from
|
|
21
|
+
* the prefix rather than declared, so the two can never disagree.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Call-site handles for every validate code.
|
|
25
|
+
*
|
|
26
|
+
* Grouped by the stage that produces them. Codes are added here as the layer that raises them
|
|
27
|
+
* lands — the table is the taxonomy, so an entry with no producer is a promise, not a record.
|
|
28
|
+
*/
|
|
29
|
+
export const VALIDATE_CODE = {
|
|
30
|
+
// ── invocation: you pointed at the wrong thing ────────────────────────────
|
|
31
|
+
/** The target path does not exist. */
|
|
32
|
+
targetNotFound: "E_VALIDATE_TARGET_NOT_FOUND",
|
|
33
|
+
/** A directory with no recipe in it — often a package root holding instance directories. */
|
|
34
|
+
noRecipe: "E_VALIDATE_NO_RECIPE",
|
|
35
|
+
/** More than one recipe candidate and no conventional name to break the tie. */
|
|
36
|
+
ambiguousRecipe: "E_VALIDATE_AMBIGUOUS_RECIPE",
|
|
37
|
+
/** A depth that needs a recipe was requested against a target that has none. */
|
|
38
|
+
needsRecipe: "E_VALIDATE_NEEDS_RECIPE",
|
|
39
|
+
/** Inline recipe content with no directory to resolve a relative scanner path against. */
|
|
40
|
+
needsDir: "E_VALIDATE_NEEDS_DIR",
|
|
41
|
+
/** `--scanner` named something the recipe does not declare. */
|
|
42
|
+
unknownScanner: "E_VALIDATE_UNKNOWN_SCANNER",
|
|
43
|
+
/** `--wallet` is not a well-formed address. */
|
|
44
|
+
badWallet: "E_VALIDATE_BAD_WALLET",
|
|
45
|
+
// ── static: the recipe itself ─────────────────────────────────────────────
|
|
46
|
+
/** The recipe is not parseable. */
|
|
47
|
+
yamlSyntax: "E_VALIDATE_YAML_SYNTAX",
|
|
48
|
+
/** The recipe parses but violates the schema. */
|
|
49
|
+
schema: "E_VALIDATE_SCHEMA",
|
|
50
|
+
/** Two scanners share a name — they would silently share state. */
|
|
51
|
+
dupScannerName: "E_VALIDATE_DUP_SCANNER_NAME",
|
|
52
|
+
/** Two actions share a name — same problem. */
|
|
53
|
+
dupActionName: "E_VALIDATE_DUP_ACTION_NAME",
|
|
54
|
+
/** An action prompt references a placeholder nothing supplies. */
|
|
55
|
+
promptPlaceholder: "E_VALIDATE_PROMPT_PLACEHOLDER",
|
|
56
|
+
/** The exit/protection block is absent or invalid. */
|
|
57
|
+
exitPreset: "E_VALIDATE_EXIT_PRESET",
|
|
58
|
+
/** An entry action with no resolvable margin source: it starts, then declines every signal. */
|
|
59
|
+
unsized: "E_VALIDATE_UNSIZED",
|
|
60
|
+
/** An entry action with no risk guardrails. */
|
|
61
|
+
ungated: "E_VALIDATE_UNGATED",
|
|
62
|
+
/** A declared entrypoint file that is not on disk. */
|
|
63
|
+
entrypointMissing: "E_VALIDATE_ENTRYPOINT_MISSING",
|
|
64
|
+
/** A scanner path that cannot be resolved to an absolute directory. */
|
|
65
|
+
unresolvableScannerPath: "E_VALIDATE_UNRESOLVABLE_SCANNER_PATH",
|
|
66
|
+
/** A margin percentage given as a fraction — sizes a hundred times too small, silently. */
|
|
67
|
+
marginPctFraction: "E_VALIDATE_MARGIN_PCT_FRACTION",
|
|
68
|
+
/** An LLM-mode decision action with no model configured. */
|
|
69
|
+
llmNoModel: "E_VALIDATE_LLM_NO_MODEL",
|
|
70
|
+
// ── import: will the code load ────────────────────────────────────────────
|
|
71
|
+
/** A syntax error in some file under the scanner root — including files never imported. */
|
|
72
|
+
syntax: "E_VALIDATE_SYNTAX",
|
|
73
|
+
/** The entrypoint's import chain raised. */
|
|
74
|
+
importFailed: "E_VALIDATE_IMPORT_FAILED",
|
|
75
|
+
/** The module imported but exposes no entry function. */
|
|
76
|
+
scanMissing: "E_VALIDATE_SCAN_MISSING",
|
|
77
|
+
/** The entry symbol exists but is not callable. */
|
|
78
|
+
scanNotCallable: "E_VALIDATE_SCAN_NOT_CALLABLE",
|
|
79
|
+
/** The entry function's signature does not match the contract. */
|
|
80
|
+
scanBadArity: "E_VALIDATE_SCAN_BAD_ARITY",
|
|
81
|
+
/** A package marker in the scanner root — invites relative imports that fail at run time. */
|
|
82
|
+
scannersIsPackage: "W_VALIDATE_SCANNERS_IS_PACKAGE",
|
|
83
|
+
/** A file shadowing a standard-library module for everything imported after it. */
|
|
84
|
+
shadowsStdlib: "W_VALIDATE_SHADOWS_STDLIB",
|
|
85
|
+
/** Data sourced outside the sanctioned client — invisible to the runtime and to this check. */
|
|
86
|
+
nonMcpSource: "W_VALIDATE_NON_MCP_SOURCE",
|
|
87
|
+
// ── live: execution, data, and output ─────────────────────────────────────
|
|
88
|
+
/** The tick raised. */
|
|
89
|
+
tickException: "E_VALIDATE_TICK_EXCEPTION",
|
|
90
|
+
/** The tick exceeded the budget its own recipe declares. */
|
|
91
|
+
tickTimeout: "E_VALIDATE_TICK_TIMEOUT",
|
|
92
|
+
/** Clean tick, no data read — nothing proves the scanner can fetch anything. */
|
|
93
|
+
tickUnproven: "E_VALIDATE_TICK_UNPROVEN",
|
|
94
|
+
/** The scanner attempted to send data out. Validation collects and reports; it never delivers. */
|
|
95
|
+
egressBlocked: "E_VALIDATE_EGRESS_BLOCKED",
|
|
96
|
+
/** The scanner attempted a state-changing operation. */
|
|
97
|
+
mcpPermission: "E_VALIDATE_MCP_PERMISSION",
|
|
98
|
+
/** Every data read failed — the scanner could not fetch anything. */
|
|
99
|
+
mcpToolError: "E_VALIDATE_MCP_TOOL_ERROR",
|
|
100
|
+
/** A data source that does not exist. Swallowed by the contract, so silent in production. */
|
|
101
|
+
unknownMcpTool: "E_VALIDATE_UNKNOWN_MCP_TOOL",
|
|
102
|
+
/** A hardcoded instrument that is not tradeable. */
|
|
103
|
+
unknownTicker: "E_VALIDATE_UNKNOWN_TICKER",
|
|
104
|
+
/** An emitted signal the runtime would reject on arrival. */
|
|
105
|
+
signalRejected: "E_VALIDATE_SIGNAL_REJECTED",
|
|
106
|
+
/** Credentials absent or partially configured. */
|
|
107
|
+
noCredentials: "E_VALIDATE_NO_CREDENTIALS",
|
|
108
|
+
/** A required runtime dependency is not installed. */
|
|
109
|
+
envMissingSdk: "E_VALIDATE_ENV_MISSING_SDK",
|
|
110
|
+
/** The import checker itself could not run — the environment, not the package. */
|
|
111
|
+
importHarnessFailed: "E_VALIDATE_IMPORT_HARNESS_FAILED",
|
|
112
|
+
/** Loading the scanner's modules did not terminate. */
|
|
113
|
+
importTimeout: "E_VALIDATE_IMPORT_TIMEOUT",
|
|
114
|
+
/** An exception was raised and caught — invisible in production, where it looks healthy. */
|
|
115
|
+
suppressedException: "W_VALIDATE_SUPPRESSED_EXCEPTION",
|
|
116
|
+
/** Some reads failed while others succeeded. */
|
|
117
|
+
someReadsFailed: "W_VALIDATE_MCP_TOOL_ERROR",
|
|
118
|
+
/** A response was fetched and none of it read — usually a key that does not exist. */
|
|
119
|
+
unusedMcpResponse: "W_VALIDATE_UNUSED_MCP_RESPONSE",
|
|
120
|
+
/** Numeric values delivered as text: arithmetic raises, but comparison silently misorders. */
|
|
121
|
+
stringNumerics: "W_VALIDATE_STRING_NUMERICS",
|
|
122
|
+
/** A clean tick that emitted nothing. Normal for a quiet scanner; worth surfacing. */
|
|
123
|
+
noSignalsEmitted: "W_VALIDATE_NO_SIGNALS_EMITTED",
|
|
124
|
+
/** Signals emitted having read nothing — output derived from no input. */
|
|
125
|
+
signalsWithoutReads: "W_VALIDATE_SIGNALS_WITHOUT_READS",
|
|
126
|
+
/** The recipe declares no author-written scanner, so there is no code to prove. */
|
|
127
|
+
noExternalScanners: "W_VALIDATE_NO_EXTERNAL_SCANNERS",
|
|
128
|
+
/** An emitted margin percentage below 1 — accepted by the schema, but likely a fraction. */
|
|
129
|
+
marginPctSuspicious: "W_VALIDATE_MARGIN_PCT_SUSPICIOUS",
|
|
130
|
+
// ── proof ─────────────────────────────────────────────────────────────────
|
|
131
|
+
/** No proof exists for this package's content. */
|
|
132
|
+
noProof: "E_VALIDATE_NO_PROOF",
|
|
133
|
+
/** A proof exists, but the package has changed since it was made. */
|
|
134
|
+
contentChanged: "E_VALIDATE_CONTENT_CHANGED",
|
|
135
|
+
/** The runtime moved since the proof was made, so it no longer describes this runtime. */
|
|
136
|
+
runtimeVersionChanged: "E_VALIDATE_RUNTIME_VERSION_CHANGED",
|
|
137
|
+
/** The run passed but the proof could not be written. Not a defect in the strategy. */
|
|
138
|
+
proofNotRecorded: "W_VALIDATE_PROOF_NOT_RECORDED",
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Metadata for every code.
|
|
142
|
+
*
|
|
143
|
+
* Typed as a total `Record`, so adding a code to {@link VALIDATE_CODE} without describing it here
|
|
144
|
+
* is a compile error rather than something a test has to notice.
|
|
145
|
+
*/
|
|
146
|
+
export const VALIDATE_CODE_META = {
|
|
147
|
+
// ── invocation ────────────────────────────────────────────────────────────
|
|
148
|
+
[VALIDATE_CODE.targetNotFound]: {
|
|
149
|
+
stage: "invocation", actor: "agent", fix_kind: "command",
|
|
150
|
+
condition: "The target path does not exist.",
|
|
151
|
+
},
|
|
152
|
+
[VALIDATE_CODE.noRecipe]: {
|
|
153
|
+
stage: "invocation", actor: "agent", fix_kind: "choice",
|
|
154
|
+
condition: "The target is a directory with no recipe in it.",
|
|
155
|
+
},
|
|
156
|
+
[VALIDATE_CODE.ambiguousRecipe]: {
|
|
157
|
+
stage: "invocation", actor: "agent", fix_kind: "choice",
|
|
158
|
+
condition: "Several recipe candidates and no conventional name to break the tie.",
|
|
159
|
+
},
|
|
160
|
+
[VALIDATE_CODE.needsRecipe]: {
|
|
161
|
+
stage: "invocation", actor: "agent", fix_kind: "command",
|
|
162
|
+
condition: "A depth requiring a recipe was requested against a target that has none.",
|
|
163
|
+
},
|
|
164
|
+
[VALIDATE_CODE.needsDir]: {
|
|
165
|
+
stage: "invocation", actor: "agent", fix_kind: "command",
|
|
166
|
+
condition: "Inline recipe content with no directory to resolve relative paths against.",
|
|
167
|
+
},
|
|
168
|
+
[VALIDATE_CODE.unknownScanner]: {
|
|
169
|
+
stage: "invocation", actor: "agent", fix_kind: "choice",
|
|
170
|
+
condition: "The named scanner is not declared by the recipe.",
|
|
171
|
+
},
|
|
172
|
+
[VALIDATE_CODE.badWallet]: {
|
|
173
|
+
stage: "invocation", actor: "agent", fix_kind: "command",
|
|
174
|
+
condition: "The supplied account address is not well formed.",
|
|
175
|
+
},
|
|
176
|
+
// ── static ────────────────────────────────────────────────────────────────
|
|
177
|
+
[VALIDATE_CODE.yamlSyntax]: {
|
|
178
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
179
|
+
condition: "The recipe cannot be parsed.",
|
|
180
|
+
},
|
|
181
|
+
[VALIDATE_CODE.schema]: {
|
|
182
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
183
|
+
condition: "The recipe parses but violates the schema.",
|
|
184
|
+
},
|
|
185
|
+
[VALIDATE_CODE.dupScannerName]: {
|
|
186
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
187
|
+
condition: "Two scanners share a name and would silently share state.",
|
|
188
|
+
},
|
|
189
|
+
[VALIDATE_CODE.dupActionName]: {
|
|
190
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
191
|
+
condition: "Two actions share a name and would silently share state.",
|
|
192
|
+
},
|
|
193
|
+
[VALIDATE_CODE.promptPlaceholder]: {
|
|
194
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
195
|
+
condition: "An action prompt references a placeholder nothing supplies.",
|
|
196
|
+
},
|
|
197
|
+
[VALIDATE_CODE.exitPreset]: {
|
|
198
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
199
|
+
condition: "The exit block is absent or invalid, leaving positions unmanaged.",
|
|
200
|
+
},
|
|
201
|
+
[VALIDATE_CODE.unsized]: {
|
|
202
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
203
|
+
condition: "An entry action has no resolvable margin source, so every signal is declined.",
|
|
204
|
+
},
|
|
205
|
+
[VALIDATE_CODE.ungated]: {
|
|
206
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
207
|
+
condition: "An entry action has no risk guardrails.",
|
|
208
|
+
},
|
|
209
|
+
[VALIDATE_CODE.entrypointMissing]: {
|
|
210
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
211
|
+
condition: "The declared entrypoint file is not on disk.",
|
|
212
|
+
},
|
|
213
|
+
[VALIDATE_CODE.unresolvableScannerPath]: {
|
|
214
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
215
|
+
condition: "A relative scanner path has no directory to resolve against.",
|
|
216
|
+
},
|
|
217
|
+
[VALIDATE_CODE.marginPctFraction]: {
|
|
218
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
219
|
+
condition: "A margin percentage is given as a fraction, sizing a hundred times too small.",
|
|
220
|
+
},
|
|
221
|
+
[VALIDATE_CODE.llmNoModel]: {
|
|
222
|
+
stage: "static", actor: "agent", fix_kind: "edit",
|
|
223
|
+
condition: "A decision action is in model mode with no model configured.",
|
|
224
|
+
},
|
|
225
|
+
// ── import ────────────────────────────────────────────────────────────────
|
|
226
|
+
[VALIDATE_CODE.syntax]: {
|
|
227
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
228
|
+
condition: "A file under the scanner root does not compile.",
|
|
229
|
+
},
|
|
230
|
+
[VALIDATE_CODE.importFailed]: {
|
|
231
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
232
|
+
condition: "The entrypoint's import chain raised.",
|
|
233
|
+
},
|
|
234
|
+
[VALIDATE_CODE.scanMissing]: {
|
|
235
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
236
|
+
condition: "The module exposes no entry function.",
|
|
237
|
+
},
|
|
238
|
+
[VALIDATE_CODE.scanNotCallable]: {
|
|
239
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
240
|
+
condition: "The entry symbol exists but is not callable.",
|
|
241
|
+
},
|
|
242
|
+
[VALIDATE_CODE.scanBadArity]: {
|
|
243
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
244
|
+
condition: "The entry function's signature does not match the contract.",
|
|
245
|
+
},
|
|
246
|
+
[VALIDATE_CODE.scannersIsPackage]: {
|
|
247
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
248
|
+
condition: "A package marker in the scanner root invites relative imports that fail at run time.",
|
|
249
|
+
},
|
|
250
|
+
[VALIDATE_CODE.shadowsStdlib]: {
|
|
251
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
252
|
+
condition: "A file shadows a standard-library module for everything imported after it.",
|
|
253
|
+
},
|
|
254
|
+
[VALIDATE_CODE.nonMcpSource]: {
|
|
255
|
+
stage: "import", actor: "agent", fix_kind: "edit",
|
|
256
|
+
condition: "Data is sourced outside the sanctioned client, invisible to the runtime.",
|
|
257
|
+
},
|
|
258
|
+
// ── live ──────────────────────────────────────────────────────────────────
|
|
259
|
+
[VALIDATE_CODE.tickException]: {
|
|
260
|
+
stage: "live", actor: "agent", fix_kind: "locate-only",
|
|
261
|
+
condition: "The tick raised.",
|
|
262
|
+
},
|
|
263
|
+
[VALIDATE_CODE.tickTimeout]: {
|
|
264
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
265
|
+
condition: "The tick exceeded the budget its own recipe declares.",
|
|
266
|
+
},
|
|
267
|
+
[VALIDATE_CODE.tickUnproven]: {
|
|
268
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
269
|
+
condition: "A clean tick that read no data, so nothing proves the scanner can fetch.",
|
|
270
|
+
},
|
|
271
|
+
[VALIDATE_CODE.egressBlocked]: {
|
|
272
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
273
|
+
condition: "The scanner attempted to send data out; validation never delivers.",
|
|
274
|
+
},
|
|
275
|
+
[VALIDATE_CODE.mcpPermission]: {
|
|
276
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
277
|
+
condition: "The scanner attempted a state-changing operation.",
|
|
278
|
+
},
|
|
279
|
+
[VALIDATE_CODE.mcpToolError]: {
|
|
280
|
+
stage: "live", actor: "agent", fix_kind: "locate-only",
|
|
281
|
+
condition: "Every data read failed, so the scanner fetched nothing.",
|
|
282
|
+
},
|
|
283
|
+
[VALIDATE_CODE.unknownMcpTool]: {
|
|
284
|
+
stage: "live", actor: "agent", fix_kind: "lookup",
|
|
285
|
+
condition: "A data source was called that the server does not expose.",
|
|
286
|
+
},
|
|
287
|
+
[VALIDATE_CODE.unknownTicker]: {
|
|
288
|
+
stage: "live", actor: "agent", fix_kind: "lookup",
|
|
289
|
+
condition: "A hardcoded instrument is not tradeable.",
|
|
290
|
+
},
|
|
291
|
+
[VALIDATE_CODE.signalRejected]: {
|
|
292
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
293
|
+
condition: "An emitted signal would be rejected by the runtime on arrival.",
|
|
294
|
+
},
|
|
295
|
+
[VALIDATE_CODE.noCredentials]: {
|
|
296
|
+
stage: "live", actor: "ops", fix_kind: "command",
|
|
297
|
+
condition: "Credentials are absent or only partially configured.",
|
|
298
|
+
},
|
|
299
|
+
[VALIDATE_CODE.envMissingSdk]: {
|
|
300
|
+
stage: "live", actor: "ops", fix_kind: "command",
|
|
301
|
+
condition: "A required runtime dependency is not installed.",
|
|
302
|
+
},
|
|
303
|
+
[VALIDATE_CODE.importHarnessFailed]: {
|
|
304
|
+
stage: "import", actor: "ops", fix_kind: "command",
|
|
305
|
+
condition: "The import checker could not be run at all.",
|
|
306
|
+
},
|
|
307
|
+
[VALIDATE_CODE.importTimeout]: {
|
|
308
|
+
stage: "import", actor: "agent", fix_kind: "locate-only",
|
|
309
|
+
condition: "Loading the scanner's modules did not terminate — work at module level.",
|
|
310
|
+
},
|
|
311
|
+
[VALIDATE_CODE.suppressedException]: {
|
|
312
|
+
stage: "live", actor: "agent", fix_kind: "locate-only",
|
|
313
|
+
condition: "An exception was raised and caught, so it is invisible in production.",
|
|
314
|
+
},
|
|
315
|
+
[VALIDATE_CODE.someReadsFailed]: {
|
|
316
|
+
stage: "live", actor: "agent", fix_kind: "locate-only",
|
|
317
|
+
condition: "Some data reads failed while others succeeded.",
|
|
318
|
+
},
|
|
319
|
+
[VALIDATE_CODE.unusedMcpResponse]: {
|
|
320
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
321
|
+
condition: "A response was fetched and none of its keys were read.",
|
|
322
|
+
},
|
|
323
|
+
[VALIDATE_CODE.stringNumerics]: {
|
|
324
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
325
|
+
condition: "Numeric values arrived as text, which compares and sorts wrongly without raising.",
|
|
326
|
+
},
|
|
327
|
+
[VALIDATE_CODE.noSignalsEmitted]: {
|
|
328
|
+
stage: "live", actor: "agent", fix_kind: "locate-only",
|
|
329
|
+
condition: "A clean tick emitted nothing.",
|
|
330
|
+
},
|
|
331
|
+
[VALIDATE_CODE.signalsWithoutReads]: {
|
|
332
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
333
|
+
condition: "Signals were emitted having read no data.",
|
|
334
|
+
},
|
|
335
|
+
[VALIDATE_CODE.noExternalScanners]: {
|
|
336
|
+
stage: "live", actor: "agent", fix_kind: "locate-only",
|
|
337
|
+
condition: "The recipe declares no author-written scanner, so there is no code to prove.",
|
|
338
|
+
},
|
|
339
|
+
[VALIDATE_CODE.marginPctSuspicious]: {
|
|
340
|
+
stage: "live", actor: "agent", fix_kind: "edit",
|
|
341
|
+
condition: "An emitted margin percentage below one is accepted but is probably a fraction.",
|
|
342
|
+
},
|
|
343
|
+
// ── proof ─────────────────────────────────────────────────────────────────
|
|
344
|
+
[VALIDATE_CODE.noProof]: {
|
|
345
|
+
stage: "proof", actor: "agent", fix_kind: "command",
|
|
346
|
+
condition: "No proof exists for this package's content.",
|
|
347
|
+
},
|
|
348
|
+
[VALIDATE_CODE.contentChanged]: {
|
|
349
|
+
stage: "proof", actor: "agent", fix_kind: "command",
|
|
350
|
+
condition: "The package has changed since its proof was made.",
|
|
351
|
+
},
|
|
352
|
+
[VALIDATE_CODE.runtimeVersionChanged]: {
|
|
353
|
+
stage: "proof", actor: "agent", fix_kind: "command",
|
|
354
|
+
condition: "The runtime moved since the proof was made.",
|
|
355
|
+
},
|
|
356
|
+
[VALIDATE_CODE.proofNotRecorded]: {
|
|
357
|
+
stage: "proof", actor: "ops", fix_kind: "command",
|
|
358
|
+
condition: "The run passed but its proof could not be written.",
|
|
359
|
+
},
|
|
360
|
+
};
|
|
361
|
+
/** Every code, in declaration order. */
|
|
362
|
+
export const ALL_VALIDATE_CODES = Object.values(VALIDATE_CODE);
|
|
363
|
+
/**
|
|
364
|
+
* Severity for a code, derived from its prefix so the two can never disagree.
|
|
365
|
+
*
|
|
366
|
+
* `E_` fails the run. `W_` is reported and only fails under `--strict`.
|
|
367
|
+
*/
|
|
368
|
+
export function severityOf(code) {
|
|
369
|
+
return code.startsWith("W_") ? "warning" : "error";
|
|
370
|
+
}
|
|
371
|
+
/** Every code raised at a given depth. Used to scope coverage while stages are still being built. */
|
|
372
|
+
export function codesForStage(stage) {
|
|
373
|
+
return ALL_VALIDATE_CODES.filter((code) => VALIDATE_CODE_META[code].stage === stage);
|
|
374
|
+
}
|
|
375
|
+
//# sourceMappingURL=codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../src/validate/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,6EAA6E;IAC7E,sCAAsC;IACtC,cAAc,EAAE,6BAA6B;IAC7C,4FAA4F;IAC5F,QAAQ,EAAE,sBAAsB;IAChC,gFAAgF;IAChF,eAAe,EAAE,6BAA6B;IAC9C,gFAAgF;IAChF,WAAW,EAAE,yBAAyB;IACtC,0FAA0F;IAC1F,QAAQ,EAAE,sBAAsB;IAChC,+DAA+D;IAC/D,cAAc,EAAE,4BAA4B;IAC5C,+CAA+C;IAC/C,SAAS,EAAE,uBAAuB;IAElC,6EAA6E;IAC7E,mCAAmC;IACnC,UAAU,EAAE,wBAAwB;IACpC,iDAAiD;IACjD,MAAM,EAAE,mBAAmB;IAC3B,mEAAmE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GAA4B,MAAM,CAAC,MAAM,CACtE,aAAa,CACI,CAAC;AAEpB;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAkB;IAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AACrD,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage accounting for the finding taxonomy.
|
|
3
|
+
*
|
|
4
|
+
* The premise of `senpi validate` is that its messages are the product — so a code that no test
|
|
5
|
+
* ever produces is a message nobody has read. A hand-maintained checklist of "codes we tested"
|
|
6
|
+
* rots the first time someone is in a hurry; this makes the accounting mechanical instead.
|
|
7
|
+
*
|
|
8
|
+
* Pure functions over an observed set. The suite that collects real findings feeds them in; these
|
|
9
|
+
* decide what is missing. Nothing here reads the filesystem or knows how findings are produced.
|
|
10
|
+
*/
|
|
11
|
+
import { type ValidateCode } from "./codes.js";
|
|
12
|
+
import type { ValidationStage } from "./types.js";
|
|
13
|
+
export interface CoverageOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Only account for codes raised at these depths.
|
|
16
|
+
*
|
|
17
|
+
* Exists because the taxonomy is declared whole while the checks that raise it are built in
|
|
18
|
+
* layers. Scoping to the stages that exist keeps the assertion meaningful — and honest — instead
|
|
19
|
+
* of permanently red or, worse, permanently disabled. Widen this as each layer lands; the day it
|
|
20
|
+
* covers every stage, the option can go.
|
|
21
|
+
*/
|
|
22
|
+
stages: readonly ValidationStage[];
|
|
23
|
+
}
|
|
24
|
+
/** Codes that should have been produced by some test, and were not. */
|
|
25
|
+
export declare function findUncoveredCodes(observed: Iterable<string>, options: CoverageOptions): ValidateCode[];
|
|
26
|
+
/**
|
|
27
|
+
* Observed codes that are not in the taxonomy at all.
|
|
28
|
+
*
|
|
29
|
+
* Catches the opposite failure from {@link findUncoveredCodes}: a finding emitted with a
|
|
30
|
+
* hand-written string that never made it into the table, so it has no metadata, no entry in the
|
|
31
|
+
* generated reference, and no route through the actor/fix-kind logic that depends on it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function findUnknownCodes(observed: Iterable<string>): string[];
|
|
34
|
+
//# sourceMappingURL=coverage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/validate/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAA0C,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CACpC;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC1B,OAAO,EAAE,eAAe,GACvB,YAAY,EAAE,CAMhB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAOrE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coverage accounting for the finding taxonomy.
|
|
3
|
+
*
|
|
4
|
+
* The premise of `senpi validate` is that its messages are the product — so a code that no test
|
|
5
|
+
* ever produces is a message nobody has read. A hand-maintained checklist of "codes we tested"
|
|
6
|
+
* rots the first time someone is in a hurry; this makes the accounting mechanical instead.
|
|
7
|
+
*
|
|
8
|
+
* Pure functions over an observed set. The suite that collects real findings feeds them in; these
|
|
9
|
+
* decide what is missing. Nothing here reads the filesystem or knows how findings are produced.
|
|
10
|
+
*/
|
|
11
|
+
import { ALL_VALIDATE_CODES, VALIDATE_CODE_META } from "./codes.js";
|
|
12
|
+
/** Codes that should have been produced by some test, and were not. */
|
|
13
|
+
export function findUncoveredCodes(observed, options) {
|
|
14
|
+
const seen = new Set(observed);
|
|
15
|
+
const inScope = new Set(options.stages);
|
|
16
|
+
return ALL_VALIDATE_CODES.filter((code) => inScope.has(VALIDATE_CODE_META[code].stage) && !seen.has(code));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Observed codes that are not in the taxonomy at all.
|
|
20
|
+
*
|
|
21
|
+
* Catches the opposite failure from {@link findUncoveredCodes}: a finding emitted with a
|
|
22
|
+
* hand-written string that never made it into the table, so it has no metadata, no entry in the
|
|
23
|
+
* generated reference, and no route through the actor/fix-kind logic that depends on it.
|
|
24
|
+
*/
|
|
25
|
+
export function findUnknownCodes(observed) {
|
|
26
|
+
const known = new Set(ALL_VALIDATE_CODES);
|
|
27
|
+
const unknown = new Set();
|
|
28
|
+
for (const code of observed) {
|
|
29
|
+
if (!known.has(code))
|
|
30
|
+
unknown.add(code);
|
|
31
|
+
}
|
|
32
|
+
return [...unknown].sort();
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/validate/coverage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAqB,MAAM,YAAY,CAAC;AAevF,uEAAuE;AACvE,MAAM,UAAU,kBAAkB,CAChC,QAA0B,EAC1B,OAAwB;IAExB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAkB,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,OAAO,kBAAkB,CAAC,MAAM,CAC9B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CACzE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA0B;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,kBAAkB,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The import depth: run the loadability checks and turn what they find into findings.
|
|
3
|
+
*
|
|
4
|
+
* The checks themselves live in Python, next to the loader the scaffold uses before its own first
|
|
5
|
+
* tick — so a package that passes has satisfied the contract production applies. This side spawns
|
|
6
|
+
* that checker, one process per scanner, and translates its output.
|
|
7
|
+
*
|
|
8
|
+
* ## Why a process per scanner
|
|
9
|
+
*
|
|
10
|
+
* Importing puts the scanner's directory at the front of the module search path, and two scanners
|
|
11
|
+
* routinely contain files of the same name. Checking several in one interpreter lets one scanner's
|
|
12
|
+
* `scoring` satisfy another's import of a file that does not exist — a broken package reporting
|
|
13
|
+
* clean. Production spawns a process per scanner for the same reason, so this matches it.
|
|
14
|
+
*/
|
|
15
|
+
import type { Finding } from "./types.js";
|
|
16
|
+
/** One scanner to check: where its code lives and which file is the entry. */
|
|
17
|
+
export interface ScannerTarget {
|
|
18
|
+
/** Recipe name, or a stand-in when checking a bare directory. */
|
|
19
|
+
name: string;
|
|
20
|
+
root: string;
|
|
21
|
+
entrypoint?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Raw shape emitted by the Python checker. Field presence varies by code. */
|
|
24
|
+
interface RawFinding {
|
|
25
|
+
code: string;
|
|
26
|
+
file?: string;
|
|
27
|
+
line?: number | null;
|
|
28
|
+
message?: string;
|
|
29
|
+
module?: string;
|
|
30
|
+
error_type?: string;
|
|
31
|
+
where?: {
|
|
32
|
+
file: string;
|
|
33
|
+
line: number;
|
|
34
|
+
} | null;
|
|
35
|
+
import_chain?: string[];
|
|
36
|
+
traceback?: string;
|
|
37
|
+
}
|
|
38
|
+
/** The directory the `scaffold` package is importable from, in dev and in the built package alike. */
|
|
39
|
+
export declare function scaffoldPackageDir(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Turn one raw result into findings.
|
|
42
|
+
*
|
|
43
|
+
* The Python side reports *what it observed*; the reasons and remedies are composed here, so all
|
|
44
|
+
* message policy lives in one language rather than being split across the boundary.
|
|
45
|
+
*/
|
|
46
|
+
export declare function toFindings(scanner: ScannerTarget, raw: RawFinding): Finding[];
|
|
47
|
+
/** Run the Python checker for one scanner. */
|
|
48
|
+
export declare function checkScanner(scanner: ScannerTarget, options?: {
|
|
49
|
+
pythonBin?: string;
|
|
50
|
+
cwd?: string;
|
|
51
|
+
budgetMs?: number;
|
|
52
|
+
}): Promise<Finding[]>;
|
|
53
|
+
/** Absolute scanner root for a declared path, resolved against the recipe's directory. */
|
|
54
|
+
export declare function resolveRoot(declared: string, baseDir: string | undefined): string | undefined;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=import-stage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-stage.d.ts","sourceRoot":"","sources":["../../src/validate/import-stage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,OAAO,EAA4B,MAAM,YAAY,CAAC;AAUpE,8EAA8E;AAC9E,MAAM,WAA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