@redditech/agent-protocol 0.0.0-stage → 0.2.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/CHANGELOG.md +89 -0
- package/LICENSE +21 -0
- package/README.md +394 -2
- package/dist/adl.d.ts +141 -0
- package/dist/adl.js +3601 -0
- package/dist/agent-stack-fixtures.d.ts +743 -0
- package/dist/agent-stack-fixtures.js +1554 -0
- package/dist/ai-catalog.d.ts +128 -0
- package/dist/ai-catalog.js +373 -0
- package/dist/attestation-reputation.d.ts +102 -0
- package/dist/attestation-reputation.js +279 -0
- package/dist/audd-rail-config.d.ts +102 -0
- package/dist/audd-rail-config.js +294 -0
- package/dist/browser-wallet-approval.d.ts +293 -0
- package/dist/browser-wallet-approval.js +1201 -0
- package/dist/discovery-source.d.ts +115 -0
- package/dist/discovery-source.js +251 -0
- package/dist/evidence-archive.d.ts +73 -0
- package/dist/evidence-archive.js +238 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/mpp-tempo-receipt-shapes.d.ts +201 -0
- package/dist/mpp-tempo-receipt-shapes.js +330 -0
- package/dist/okf-adapter.d.ts +229 -0
- package/dist/okf-adapter.js +556 -0
- package/dist/okf-conformance.d.ts +208 -0
- package/dist/okf-conformance.js +651 -0
- package/dist/okf-instruction-safety.d.ts +192 -0
- package/dist/okf-instruction-safety.js +509 -0
- package/dist/onboarding-analyser-handoff.d.ts +391 -0
- package/dist/onboarding-analyser-handoff.js +959 -0
- package/dist/onboarding-state-machine.d.ts +228 -0
- package/dist/onboarding-state-machine.js +432 -0
- package/dist/payment-records.d.ts +181 -0
- package/dist/payment-records.js +599 -0
- package/dist/policy.d.ts +33 -0
- package/dist/policy.js +45 -0
- package/dist/provider-trust.d.ts +113 -0
- package/dist/provider-trust.js +346 -0
- package/dist/quasar-registry-compatibility.d.ts +113 -0
- package/dist/quasar-registry-compatibility.js +214 -0
- package/dist/ranking-explainability.d.ts +202 -0
- package/dist/ranking-explainability.js +302 -0
- package/dist/receipt-v2.d.ts +202 -0
- package/dist/receipt-v2.js +418 -0
- package/dist/repo-explorer-evidence-manifest.d.ts +387 -0
- package/dist/repo-explorer-evidence-manifest.js +1187 -0
- package/dist/source-diagnostics.d.ts +84 -0
- package/dist/source-diagnostics.js +193 -0
- package/dist/source-trust-conformance-matrix.d.ts +207 -0
- package/dist/source-trust-conformance-matrix.js +672 -0
- package/examples/ard-no-spend-ai-catalog.json +51 -0
- package/examples/ard-no-spend-demo.mjs +355 -0
- package/examples/interpretation-guide-scenarios.mjs +302 -0
- package/package.json +144 -4
|
@@ -0,0 +1,1187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo explorer evidence manifest for static fixture ingestion (#470,
|
|
3
|
+
* epic #468 / #400).
|
|
4
|
+
*
|
|
5
|
+
* FastContext-style (arXiv:2606.14066) exploration/solve split, RAP-owned:
|
|
6
|
+
* repository EXPLORATION is read-only and returns compact file/line citations
|
|
7
|
+
* with short relevance reasons — never broad context dumps and never a
|
|
8
|
+
* full-repo ingest. This module defines the typed contract for that evidence
|
|
9
|
+
* (`reddi.repo-explorer-evidence-manifest.v1`), validates candidate manifests
|
|
10
|
+
* fail-closed, bridges accepted manifests onto the #509/#575 onboarding
|
|
11
|
+
* `static-agent-stack-snapshot` / `snapshotRef` provenance surface by
|
|
12
|
+
* reference, and projects them toward the shipped #403/#404/#421/#405/#406
|
|
13
|
+
* vocabularies.
|
|
14
|
+
*
|
|
15
|
+
* The manifest DESCRIBES exploration evidence a caller already holds; this
|
|
16
|
+
* module never performs exploration. It mirrors the shape of the OpenClaw-side
|
|
17
|
+
* `openclaw.repo-explorer-evidence.v0.1` schema but is RAP-owned and
|
|
18
|
+
* self-contained — not an import, not a runtime dependency.
|
|
19
|
+
*
|
|
20
|
+
* This module is PURE and self-contained (zero imports — the #575/#584/#585
|
|
21
|
+
* pattern): no network, no filesystem access, no repo fetch/clone, no URL
|
|
22
|
+
* ingestion, no dependency install, no LLM/provider call, no MCP/tool call,
|
|
23
|
+
* no script or hook execution, no service startup, no wallet/RPC, no payment
|
|
24
|
+
* activation, no hosted write, no marketplace publication, no
|
|
25
|
+
* trust/reputation mutation. It only analyses in-memory data the caller
|
|
26
|
+
* already holds. Fail-closed on malformed input and on any request to
|
|
27
|
+
* fetch/clone/execute/install/ingest.
|
|
28
|
+
*
|
|
29
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
30
|
+
* REVIEW-ONLY BOUNDARY: explorer evidence is LOCALIZATION EVIDENCE for static
|
|
31
|
+
* review — never approval to install, run, execute, or adopt the explored
|
|
32
|
+
* repository or any content it cites. A `valid` verdict permits static
|
|
33
|
+
* review/analysis and provenance attachment ONLY. Those denials hold
|
|
34
|
+
* regardless of verdict — see `reviewBoundary` on every report.
|
|
35
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
36
|
+
*/
|
|
37
|
+
export const REPO_EXPLORER_EVIDENCE_MANIFEST_SCHEMA_VERSION = 'reddi.repo-explorer-evidence-manifest.v1';
|
|
38
|
+
/** Source trust boundary — hard-coded. Explored repositories are always
|
|
39
|
+
* external and untrusted; imported content can never self-assert trust. */
|
|
40
|
+
export const REPO_EXPLORER_SOURCE_TRUST = 'external_untrusted';
|
|
41
|
+
/** The read-only explorer contract statement carried verbatim on every
|
|
42
|
+
* normalized manifest. */
|
|
43
|
+
export const REPO_EXPLORER_READ_ONLY_CONTRACT = 'Read-only exploration evidence: this manifest DESCRIBES observed repository content (file paths, line ranges, short relevance reasons). It is localization evidence for static review only — never approval to install, run, execute, ingest, or adopt the explored repository or any content it cites.';
|
|
44
|
+
export const REPO_EXPLORER_DEFAULT_TOOLS_ALLOWED = Object.freeze([
|
|
45
|
+
'list_files',
|
|
46
|
+
'read_file',
|
|
47
|
+
'search_text',
|
|
48
|
+
]);
|
|
49
|
+
export const REPO_EXPLORER_DEFAULT_TOOLS_FORBIDDEN = Object.freeze([
|
|
50
|
+
'execute',
|
|
51
|
+
'install',
|
|
52
|
+
'network_fetch',
|
|
53
|
+
'write_file',
|
|
54
|
+
'spawn_process',
|
|
55
|
+
]);
|
|
56
|
+
/** What an accepted manifest permits — and what stays permanently denied. */
|
|
57
|
+
export const REPO_EXPLORER_EVIDENCE_PERMITTED_USE = [
|
|
58
|
+
'static_review',
|
|
59
|
+
'static_analysis',
|
|
60
|
+
'fixture_ingestion_provenance',
|
|
61
|
+
'operator_review_payload',
|
|
62
|
+
'conformance_reporting',
|
|
63
|
+
];
|
|
64
|
+
export const REPO_EXPLORER_EVIDENCE_DENIED_USE = [
|
|
65
|
+
'repo_fetch_or_clone',
|
|
66
|
+
'full_repo_ingestion',
|
|
67
|
+
'dependency_install',
|
|
68
|
+
'script_or_tool_execution',
|
|
69
|
+
'skill_installation',
|
|
70
|
+
'agent_registration',
|
|
71
|
+
'marketplace_publication',
|
|
72
|
+
'hosted_registry_write',
|
|
73
|
+
'llm_or_provider_call',
|
|
74
|
+
'wallet_or_rpc_call',
|
|
75
|
+
'payment_activation',
|
|
76
|
+
'trust_or_reputation_mutation',
|
|
77
|
+
];
|
|
78
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
79
|
+
* Default generated/noisy path vocabulary
|
|
80
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
81
|
+
/** Directory segments that mark generated/vendored/noisy content. */
|
|
82
|
+
export const REPO_EXPLORER_NOISY_SEGMENTS = Object.freeze([
|
|
83
|
+
'node_modules',
|
|
84
|
+
'dist',
|
|
85
|
+
'build',
|
|
86
|
+
'out',
|
|
87
|
+
'.next',
|
|
88
|
+
'coverage',
|
|
89
|
+
'vendor',
|
|
90
|
+
'.git',
|
|
91
|
+
'target',
|
|
92
|
+
'__pycache__',
|
|
93
|
+
'.venv',
|
|
94
|
+
]);
|
|
95
|
+
/** Basename suffixes that mark generated/minified/noisy content. */
|
|
96
|
+
export const REPO_EXPLORER_NOISY_SUFFIXES = Object.freeze([
|
|
97
|
+
'.lock',
|
|
98
|
+
'.min.js',
|
|
99
|
+
'.min.css',
|
|
100
|
+
'.map',
|
|
101
|
+
'.snap',
|
|
102
|
+
'.tsbuildinfo',
|
|
103
|
+
]);
|
|
104
|
+
/** Exact basenames that mark generated lockfile/noise content. */
|
|
105
|
+
export const REPO_EXPLORER_NOISY_BASENAMES = Object.freeze([
|
|
106
|
+
'package-lock.json',
|
|
107
|
+
'yarn.lock',
|
|
108
|
+
'pnpm-lock.yaml',
|
|
109
|
+
'bun.lockb',
|
|
110
|
+
'cargo.lock',
|
|
111
|
+
]);
|
|
112
|
+
/** Deterministic generated/noisy classification for a repo-relative path. */
|
|
113
|
+
export function isGeneratedOrNoisyPath(path) {
|
|
114
|
+
const segments = path.split('/');
|
|
115
|
+
for (const segment of segments.slice(0, -1)) {
|
|
116
|
+
if (REPO_EXPLORER_NOISY_SEGMENTS.includes(segment.toLowerCase())) {
|
|
117
|
+
return { noisy: true, matched: segment.toLowerCase() };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const basename = (segments[segments.length - 1] ?? '').toLowerCase();
|
|
121
|
+
if (REPO_EXPLORER_NOISY_BASENAMES.includes(basename)) {
|
|
122
|
+
return { noisy: true, matched: basename };
|
|
123
|
+
}
|
|
124
|
+
for (const suffix of REPO_EXPLORER_NOISY_SUFFIXES) {
|
|
125
|
+
if (basename.endsWith(suffix)) {
|
|
126
|
+
return { noisy: true, matched: suffix };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { noisy: false, matched: null };
|
|
130
|
+
}
|
|
131
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
132
|
+
* Path safety (fail-closed)
|
|
133
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
134
|
+
const URI_SCHEME_OR_DRIVE_PATTERN = /^[a-z][a-z0-9+.-]*:/i;
|
|
135
|
+
const CONTROL_CHAR_PATTERN = /[\u0000-\u001f\u007f]/;
|
|
136
|
+
const ENCODED_TRAVERSAL_PATTERN = /%2e%2e|%2f|%5c/i;
|
|
137
|
+
const RFC3339_UTC_PATTERN = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/;
|
|
138
|
+
const COMMIT_SHA_PATTERN = /^[0-9a-f]{7,64}$/;
|
|
139
|
+
/**
|
|
140
|
+
* Deterministic fail-closed safety check for a repo-root-relative citation
|
|
141
|
+
* path. Rejects: empty/non-string paths, control characters, backslash
|
|
142
|
+
* separators, URI schemes (`file://`, `http://`, …) and Windows drive
|
|
143
|
+
* prefixes, absolute paths, home-directory expansion, `..` traversal
|
|
144
|
+
* (literal or percent-encoded), and empty/`.` segments.
|
|
145
|
+
*/
|
|
146
|
+
export function repoRelativePathProblem(value) {
|
|
147
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
148
|
+
return { code: 'malformed_evidence_path', message: 'path must be a non-empty string' };
|
|
149
|
+
}
|
|
150
|
+
const path = value.trim();
|
|
151
|
+
if (CONTROL_CHAR_PATTERN.test(path)) {
|
|
152
|
+
return { code: 'malformed_evidence_path', message: 'path contains control characters' };
|
|
153
|
+
}
|
|
154
|
+
if (path.includes('\\')) {
|
|
155
|
+
return { code: 'malformed_evidence_path', message: 'path uses backslash separators; only repo-relative POSIX paths are accepted' };
|
|
156
|
+
}
|
|
157
|
+
if (URI_SCHEME_OR_DRIVE_PATTERN.test(path)) {
|
|
158
|
+
return { code: 'unsafe_evidence_path', message: 'path carries a URI scheme or drive prefix (e.g. file://, https://, C:); only repo-relative paths are accepted' };
|
|
159
|
+
}
|
|
160
|
+
if (path.startsWith('/')) {
|
|
161
|
+
return { code: 'unsafe_evidence_path', message: 'absolute paths are not accepted; paths must be repo-root-relative' };
|
|
162
|
+
}
|
|
163
|
+
if (path.startsWith('~')) {
|
|
164
|
+
return { code: 'unsafe_evidence_path', message: 'home-directory expansion is not accepted; paths must be repo-root-relative' };
|
|
165
|
+
}
|
|
166
|
+
if (ENCODED_TRAVERSAL_PATTERN.test(path)) {
|
|
167
|
+
return { code: 'unsafe_evidence_path', message: 'percent-encoded separators/traversal sequences are not accepted' };
|
|
168
|
+
}
|
|
169
|
+
const segments = path.split('/');
|
|
170
|
+
for (const segment of segments) {
|
|
171
|
+
if (segment === '..') {
|
|
172
|
+
return { code: 'unsafe_evidence_path', message: 'path traversal (`..`) is not accepted' };
|
|
173
|
+
}
|
|
174
|
+
if (segment === '' || segment === '.') {
|
|
175
|
+
return { code: 'malformed_evidence_path', message: 'empty or `.` path segments are not accepted' };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
181
|
+
* Validation (fail-closed)
|
|
182
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
183
|
+
const MAX_REASON_LENGTH = 500;
|
|
184
|
+
const READ_ONLY_VIOLATION_TOOL_PATTERN = /(execute|exec|install|write|network|fetch|spawn|shell|run|delete|mutate)/i;
|
|
185
|
+
const EXCLUSION_KINDS = [
|
|
186
|
+
'generated',
|
|
187
|
+
'noisy',
|
|
188
|
+
'binary',
|
|
189
|
+
'irrelevant',
|
|
190
|
+
'secret_risk',
|
|
191
|
+
];
|
|
192
|
+
/**
|
|
193
|
+
* Validates a candidate repo explorer evidence manifest, fail-closed.
|
|
194
|
+
* Pure static analysis over in-memory data: nothing is fetched, read from
|
|
195
|
+
* disk, executed, or ingested. A `blocked` verdict yields `manifest: null`.
|
|
196
|
+
*/
|
|
197
|
+
export function validateRepoExplorerEvidenceManifest(input, options = {}) {
|
|
198
|
+
const diagnostics = [];
|
|
199
|
+
// FAIL-CLOSED operation refusals come first and always block.
|
|
200
|
+
for (const [flag, label] of [
|
|
201
|
+
['fetchRepo', 'repository fetch'],
|
|
202
|
+
['cloneRepo', 'repository clone'],
|
|
203
|
+
['ingestFullRepo', 'full-repo ingestion'],
|
|
204
|
+
['executeContent', 'content execution'],
|
|
205
|
+
['installDependencies', 'dependency installation'],
|
|
206
|
+
['invokeLlm', 'LLM/provider invocation'],
|
|
207
|
+
]) {
|
|
208
|
+
if (options[flag] === true) {
|
|
209
|
+
diagnostics.push({
|
|
210
|
+
severity: 'blocked',
|
|
211
|
+
code: 'operation_not_permitted',
|
|
212
|
+
path: `$options.${flag}`,
|
|
213
|
+
message: `${label} was requested and is never permitted; this module only validates evidence the caller already holds.`,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!isPlainObject(input)) {
|
|
218
|
+
diagnostics.push({
|
|
219
|
+
severity: 'blocked',
|
|
220
|
+
code: 'manifest_malformed',
|
|
221
|
+
path: '$',
|
|
222
|
+
message: 'manifest must be a plain object',
|
|
223
|
+
});
|
|
224
|
+
return buildReport(null, diagnostics);
|
|
225
|
+
}
|
|
226
|
+
// ── source ────────────────────────────────────────────────────────────────
|
|
227
|
+
let repoUrl = '';
|
|
228
|
+
let resolvedCommit = '';
|
|
229
|
+
let defaultBranch;
|
|
230
|
+
const source = input['source'];
|
|
231
|
+
if (!isPlainObject(source)) {
|
|
232
|
+
diagnostics.push({
|
|
233
|
+
severity: 'blocked',
|
|
234
|
+
code: 'source_malformed',
|
|
235
|
+
path: '$.source',
|
|
236
|
+
message: 'source must be an object with repoUrl and resolvedCommit',
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const urlProblem = sourceUrlProblem(source['repoUrl']);
|
|
241
|
+
if (urlProblem !== null) {
|
|
242
|
+
diagnostics.push({
|
|
243
|
+
severity: 'blocked',
|
|
244
|
+
code: urlProblem.code,
|
|
245
|
+
path: '$.source.repoUrl',
|
|
246
|
+
message: urlProblem.message,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
repoUrl = source['repoUrl'].trim();
|
|
251
|
+
}
|
|
252
|
+
const commit = source['resolvedCommit'];
|
|
253
|
+
const normalizedCommit = typeof commit === 'string' ? commit.trim().toLowerCase() : '';
|
|
254
|
+
if (!COMMIT_SHA_PATTERN.test(normalizedCommit)) {
|
|
255
|
+
diagnostics.push({
|
|
256
|
+
severity: 'blocked',
|
|
257
|
+
code: 'commit_unresolved',
|
|
258
|
+
path: '$.source.resolvedCommit',
|
|
259
|
+
message: 'resolvedCommit must be a resolved 7-64 character hex commit SHA (branch names, tags, and HEAD are not resolved commits)',
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
resolvedCommit = normalizedCommit;
|
|
264
|
+
}
|
|
265
|
+
if (source['defaultBranch'] !== undefined) {
|
|
266
|
+
if (isNonEmptyString(source['defaultBranch'])) {
|
|
267
|
+
defaultBranch = source['defaultBranch'].trim();
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
diagnostics.push({
|
|
271
|
+
severity: 'warning',
|
|
272
|
+
code: 'source_malformed',
|
|
273
|
+
path: '$.source.defaultBranch',
|
|
274
|
+
message: 'defaultBranch must be a non-empty string when present; it was dropped',
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// ── trust boundary ────────────────────────────────────────────────────────
|
|
280
|
+
if (input['sourceTrust'] !== undefined && input['sourceTrust'] !== REPO_EXPLORER_SOURCE_TRUST) {
|
|
281
|
+
diagnostics.push({
|
|
282
|
+
severity: 'blocked',
|
|
283
|
+
code: 'trust_boundary_invalid',
|
|
284
|
+
path: '$.sourceTrust',
|
|
285
|
+
message: `sourceTrust is hard-coded '${REPO_EXPLORER_SOURCE_TRUST}'; explored repositories can never self-assert a higher trust level`,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
// ── timestamp ─────────────────────────────────────────────────────────────
|
|
289
|
+
let generatedAt = '';
|
|
290
|
+
if (typeof input['generatedAt'] !== 'string' || !RFC3339_UTC_PATTERN.test(input['generatedAt'].trim())) {
|
|
291
|
+
diagnostics.push({
|
|
292
|
+
severity: 'blocked',
|
|
293
|
+
code: 'timestamp_malformed',
|
|
294
|
+
path: '$.generatedAt',
|
|
295
|
+
message: 'generatedAt must be an RFC3339 UTC timestamp (e.g. 2026-07-06T00:00:00Z); evidence without a capture time is not acceptable provenance',
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
generatedAt = input['generatedAt'].trim();
|
|
300
|
+
}
|
|
301
|
+
// ── query ─────────────────────────────────────────────────────────────────
|
|
302
|
+
let explorationQuery = '';
|
|
303
|
+
if (!isNonEmptyString(input['explorationQuery'])) {
|
|
304
|
+
diagnostics.push({
|
|
305
|
+
severity: 'blocked',
|
|
306
|
+
code: 'query_missing',
|
|
307
|
+
path: '$.explorationQuery',
|
|
308
|
+
message: 'explorationQuery must be a non-empty, task-specific exploration query',
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
explorationQuery = input['explorationQuery'].trim();
|
|
313
|
+
}
|
|
314
|
+
// ── explorer contract ─────────────────────────────────────────────────────
|
|
315
|
+
const explorer = normalizeExplorerContract(input['explorer'], diagnostics);
|
|
316
|
+
// ── exclusions ────────────────────────────────────────────────────────────
|
|
317
|
+
const exclusions = normalizeExclusions(input['exclusions'], diagnostics);
|
|
318
|
+
// ── evidence ──────────────────────────────────────────────────────────────
|
|
319
|
+
const evidence = normalizeEvidence(input['evidence'], exclusions, explorer, diagnostics);
|
|
320
|
+
// ── open questions ────────────────────────────────────────────────────────
|
|
321
|
+
const openQuestions = normalizeOpenQuestions(input['openQuestions'], diagnostics);
|
|
322
|
+
// ── manifest id ───────────────────────────────────────────────────────────
|
|
323
|
+
let manifestId = '';
|
|
324
|
+
if (input['manifestId'] !== undefined) {
|
|
325
|
+
if (isNonEmptyString(input['manifestId'])) {
|
|
326
|
+
manifestId = input['manifestId'].trim();
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
diagnostics.push({
|
|
330
|
+
severity: 'warning',
|
|
331
|
+
code: 'manifest_malformed',
|
|
332
|
+
path: '$.manifestId',
|
|
333
|
+
message: 'manifestId must be a non-empty string when present; a deterministic id was derived instead',
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (manifestId === '' && repoUrl !== '' && resolvedCommit !== '') {
|
|
338
|
+
manifestId = deriveManifestId(repoUrl, resolvedCommit);
|
|
339
|
+
}
|
|
340
|
+
const blocked = diagnostics.some((diag) => diag.severity === 'blocked');
|
|
341
|
+
if (blocked) {
|
|
342
|
+
return buildReport(null, diagnostics);
|
|
343
|
+
}
|
|
344
|
+
const manifest = {
|
|
345
|
+
schemaVersion: REPO_EXPLORER_EVIDENCE_MANIFEST_SCHEMA_VERSION,
|
|
346
|
+
manifestId,
|
|
347
|
+
generatedAt,
|
|
348
|
+
source: {
|
|
349
|
+
repoUrl,
|
|
350
|
+
resolvedCommit,
|
|
351
|
+
...(defaultBranch === undefined ? {} : { defaultBranch }),
|
|
352
|
+
},
|
|
353
|
+
sourceTrust: REPO_EXPLORER_SOURCE_TRUST,
|
|
354
|
+
explorationQuery,
|
|
355
|
+
explorer,
|
|
356
|
+
readOnlyContract: REPO_EXPLORER_READ_ONLY_CONTRACT,
|
|
357
|
+
evidence,
|
|
358
|
+
exclusions,
|
|
359
|
+
openQuestions,
|
|
360
|
+
fullRepoIngested: false,
|
|
361
|
+
staticOnly: true,
|
|
362
|
+
};
|
|
363
|
+
return buildReport(manifest, diagnostics);
|
|
364
|
+
}
|
|
365
|
+
function buildReport(manifest, diagnostics) {
|
|
366
|
+
const blocked = diagnostics.some((diag) => diag.severity === 'blocked');
|
|
367
|
+
const verdict = blocked
|
|
368
|
+
? 'blocked'
|
|
369
|
+
: diagnostics.some((diag) => diag.severity === 'warning')
|
|
370
|
+
? 'warning'
|
|
371
|
+
: 'valid';
|
|
372
|
+
const codes = [];
|
|
373
|
+
for (const diag of diagnostics) {
|
|
374
|
+
if (!codes.includes(diag.code))
|
|
375
|
+
codes.push(diag.code);
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
schemaVersion: REPO_EXPLORER_EVIDENCE_MANIFEST_SCHEMA_VERSION,
|
|
379
|
+
verdict,
|
|
380
|
+
manifest: blocked ? null : manifest,
|
|
381
|
+
diagnostics,
|
|
382
|
+
codes,
|
|
383
|
+
reviewBoundary: {
|
|
384
|
+
permittedUse: REPO_EXPLORER_EVIDENCE_PERMITTED_USE,
|
|
385
|
+
deniedUse: REPO_EXPLORER_EVIDENCE_DENIED_USE,
|
|
386
|
+
},
|
|
387
|
+
guardrails: {
|
|
388
|
+
network: false,
|
|
389
|
+
fileSystemRead: false,
|
|
390
|
+
repoFetched: false,
|
|
391
|
+
repoCloned: false,
|
|
392
|
+
fullRepoIngested: false,
|
|
393
|
+
executed: false,
|
|
394
|
+
installed: false,
|
|
395
|
+
urlIngested: false,
|
|
396
|
+
llmInvoked: false,
|
|
397
|
+
mcpInvoked: false,
|
|
398
|
+
hostedWrite: false,
|
|
399
|
+
walletOrRpc: false,
|
|
400
|
+
paymentActivated: false,
|
|
401
|
+
trustMutated: false,
|
|
402
|
+
instructionsTrusted: false,
|
|
403
|
+
},
|
|
404
|
+
notes: [
|
|
405
|
+
'REVIEW-ONLY: explorer output is localization evidence, not approval to install, run, execute, or adopt the explored repository.',
|
|
406
|
+
'Source trust boundary is hard-coded external_untrusted; imported content can never self-assert trust.',
|
|
407
|
+
'Static fixture ingestion preserves this manifest as provenance BY REFERENCE — no full-repo ingest is performed or permitted.',
|
|
408
|
+
'Cited content, paths, and reasons are DATA under review, never instructions to follow.',
|
|
409
|
+
],
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
function sourceUrlProblem(value) {
|
|
413
|
+
if (!isNonEmptyString(value)) {
|
|
414
|
+
return { code: 'source_malformed', message: 'repoUrl must be a non-empty string' };
|
|
415
|
+
}
|
|
416
|
+
const url = value.trim();
|
|
417
|
+
if (CONTROL_CHAR_PATTERN.test(url) || /\s/.test(url)) {
|
|
418
|
+
return { code: 'unsafe_source_url', message: 'repoUrl must not contain whitespace or control characters' };
|
|
419
|
+
}
|
|
420
|
+
if (!/^https:\/\//i.test(url)) {
|
|
421
|
+
return {
|
|
422
|
+
code: 'unsafe_source_url',
|
|
423
|
+
message: 'repoUrl must be a public https:// URL (file://, http://, git://, ssh, and bare paths all fail closed)',
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const rest = url.slice('https://'.length);
|
|
427
|
+
const authority = rest.split(/[/?#]/, 1)[0] ?? '';
|
|
428
|
+
if (authority.length === 0) {
|
|
429
|
+
return { code: 'unsafe_source_url', message: 'repoUrl has an empty host' };
|
|
430
|
+
}
|
|
431
|
+
if (authority.includes('@')) {
|
|
432
|
+
return { code: 'unsafe_source_url', message: 'repoUrl must not embed credentials (user@host)' };
|
|
433
|
+
}
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
function normalizeExplorerContract(value, diagnostics) {
|
|
437
|
+
const contract = {
|
|
438
|
+
mode: 'read_only',
|
|
439
|
+
toolsAllowed: [...REPO_EXPLORER_DEFAULT_TOOLS_ALLOWED],
|
|
440
|
+
toolsForbidden: [...REPO_EXPLORER_DEFAULT_TOOLS_FORBIDDEN],
|
|
441
|
+
};
|
|
442
|
+
if (value === undefined)
|
|
443
|
+
return contract;
|
|
444
|
+
if (!isPlainObject(value)) {
|
|
445
|
+
diagnostics.push({
|
|
446
|
+
severity: 'blocked',
|
|
447
|
+
code: 'explorer_contract_invalid',
|
|
448
|
+
path: '$.explorer',
|
|
449
|
+
message: 'explorer must be an object when present',
|
|
450
|
+
});
|
|
451
|
+
return contract;
|
|
452
|
+
}
|
|
453
|
+
if (value['mode'] !== undefined && value['mode'] !== 'read_only') {
|
|
454
|
+
diagnostics.push({
|
|
455
|
+
severity: 'blocked',
|
|
456
|
+
code: 'explorer_contract_invalid',
|
|
457
|
+
path: '$.explorer.mode',
|
|
458
|
+
message: "explorer.mode must be 'read_only'; any other exploration mode fails closed",
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
for (const key of ['toolsAllowed', 'toolsForbidden']) {
|
|
462
|
+
const list = value[key];
|
|
463
|
+
if (list === undefined)
|
|
464
|
+
continue;
|
|
465
|
+
if (!Array.isArray(list) || list.some((tool) => !isNonEmptyString(tool))) {
|
|
466
|
+
diagnostics.push({
|
|
467
|
+
severity: 'blocked',
|
|
468
|
+
code: 'explorer_contract_invalid',
|
|
469
|
+
path: `$.explorer.${key}`,
|
|
470
|
+
message: `explorer.${key} must be an array of non-empty strings when present`,
|
|
471
|
+
});
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
contract[key] = list.map((tool) => tool.trim());
|
|
475
|
+
}
|
|
476
|
+
for (const tool of contract.toolsAllowed) {
|
|
477
|
+
if (READ_ONLY_VIOLATION_TOOL_PATTERN.test(tool)) {
|
|
478
|
+
diagnostics.push({
|
|
479
|
+
severity: 'blocked',
|
|
480
|
+
code: 'explorer_contract_invalid',
|
|
481
|
+
path: '$.explorer.toolsAllowed',
|
|
482
|
+
message: `allowed tool '${tool}' contradicts the read-only explorer contract (write/execute/install/network-class tools are never allowed)`,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
for (const key of ['maxFiles', 'lineWindow']) {
|
|
487
|
+
const bound = value[key];
|
|
488
|
+
if (bound === undefined)
|
|
489
|
+
continue;
|
|
490
|
+
if (typeof bound !== 'number' || !Number.isInteger(bound) || bound < 1) {
|
|
491
|
+
diagnostics.push({
|
|
492
|
+
severity: 'blocked',
|
|
493
|
+
code: 'explorer_contract_invalid',
|
|
494
|
+
path: `$.explorer.${key}`,
|
|
495
|
+
message: `explorer.${key} must be a positive integer when present`,
|
|
496
|
+
});
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
contract[key] = bound;
|
|
500
|
+
}
|
|
501
|
+
return contract;
|
|
502
|
+
}
|
|
503
|
+
function normalizeExclusions(value, diagnostics) {
|
|
504
|
+
if (value === undefined)
|
|
505
|
+
return [];
|
|
506
|
+
if (!Array.isArray(value)) {
|
|
507
|
+
diagnostics.push({
|
|
508
|
+
severity: 'blocked',
|
|
509
|
+
code: 'exclusion_entry_malformed',
|
|
510
|
+
path: '$.exclusions',
|
|
511
|
+
message: 'exclusions must be an array when present',
|
|
512
|
+
});
|
|
513
|
+
return [];
|
|
514
|
+
}
|
|
515
|
+
const exclusions = [];
|
|
516
|
+
value.forEach((entry, index) => {
|
|
517
|
+
if (!isPlainObject(entry)) {
|
|
518
|
+
diagnostics.push({
|
|
519
|
+
severity: 'blocked',
|
|
520
|
+
code: 'exclusion_entry_malformed',
|
|
521
|
+
path: `$.exclusions[${index}]`,
|
|
522
|
+
message: 'exclusion entries must be objects with path and reason',
|
|
523
|
+
});
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const rawPath = isNonEmptyString(entry['path']) ? entry['path'].trim() : '';
|
|
527
|
+
const normalizedPath = stripGlobSuffix(rawPath);
|
|
528
|
+
const pathProblem = repoRelativePathProblem(normalizedPath);
|
|
529
|
+
if (pathProblem !== null) {
|
|
530
|
+
diagnostics.push({
|
|
531
|
+
severity: 'blocked',
|
|
532
|
+
code: 'exclusion_entry_malformed',
|
|
533
|
+
path: `$.exclusions[${index}].path`,
|
|
534
|
+
message: `exclusion path is not a safe repo-relative path: ${pathProblem.message}`,
|
|
535
|
+
});
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (!isNonEmptyString(entry['reason'])) {
|
|
539
|
+
diagnostics.push({
|
|
540
|
+
severity: 'blocked',
|
|
541
|
+
code: 'exclusion_entry_malformed',
|
|
542
|
+
path: `$.exclusions[${index}].reason`,
|
|
543
|
+
message: 'exclusion entries must carry a non-empty reason',
|
|
544
|
+
});
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
let kind;
|
|
548
|
+
if (entry['kind'] !== undefined) {
|
|
549
|
+
if (EXCLUSION_KINDS.includes(entry['kind'])) {
|
|
550
|
+
kind = entry['kind'];
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
diagnostics.push({
|
|
554
|
+
severity: 'warning',
|
|
555
|
+
code: 'exclusion_entry_malformed',
|
|
556
|
+
path: `$.exclusions[${index}].kind`,
|
|
557
|
+
message: `exclusion kind must be one of ${EXCLUSION_KINDS.join(', ')} when present; it was dropped`,
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
exclusions.push({
|
|
562
|
+
path: normalizedPath,
|
|
563
|
+
reason: entry['reason'].trim(),
|
|
564
|
+
...(kind === undefined ? {} : { kind }),
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
return exclusions;
|
|
568
|
+
}
|
|
569
|
+
function normalizeEvidence(value, exclusions, explorer, diagnostics) {
|
|
570
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
571
|
+
diagnostics.push({
|
|
572
|
+
severity: 'blocked',
|
|
573
|
+
code: 'evidence_empty',
|
|
574
|
+
path: '$.evidence',
|
|
575
|
+
message: 'evidence must be a non-empty array — a manifest with no citations is not acceptable exploration evidence',
|
|
576
|
+
});
|
|
577
|
+
return [];
|
|
578
|
+
}
|
|
579
|
+
const entries = [];
|
|
580
|
+
const seen = new Set();
|
|
581
|
+
value.forEach((entry, index) => {
|
|
582
|
+
if (!isPlainObject(entry)) {
|
|
583
|
+
diagnostics.push({
|
|
584
|
+
severity: 'blocked',
|
|
585
|
+
code: 'evidence_entry_malformed',
|
|
586
|
+
path: `$.evidence[${index}]`,
|
|
587
|
+
message: 'evidence entries must be objects with path, lines, and reason',
|
|
588
|
+
});
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const pathProblem = repoRelativePathProblem(entry['path']);
|
|
592
|
+
if (pathProblem !== null) {
|
|
593
|
+
diagnostics.push({
|
|
594
|
+
severity: 'blocked',
|
|
595
|
+
code: pathProblem.code,
|
|
596
|
+
path: `$.evidence[${index}].path`,
|
|
597
|
+
message: pathProblem.message,
|
|
598
|
+
});
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
const path = entry['path'].trim();
|
|
602
|
+
const range = lineRangeProblem(entry['lines']);
|
|
603
|
+
if (typeof range === 'string') {
|
|
604
|
+
diagnostics.push({
|
|
605
|
+
severity: 'blocked',
|
|
606
|
+
code: 'invalid_line_range',
|
|
607
|
+
path: `$.evidence[${index}].lines`,
|
|
608
|
+
message: range,
|
|
609
|
+
});
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
if (!isNonEmptyString(entry['reason'])) {
|
|
613
|
+
diagnostics.push({
|
|
614
|
+
severity: 'blocked',
|
|
615
|
+
code: 'missing_relevance_reason',
|
|
616
|
+
path: `$.evidence[${index}].reason`,
|
|
617
|
+
message: 'every evidence entry must carry a short, non-empty relevance reason',
|
|
618
|
+
});
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
const reason = entry['reason'].trim();
|
|
622
|
+
if (reason.length > MAX_REASON_LENGTH) {
|
|
623
|
+
diagnostics.push({
|
|
624
|
+
severity: 'warning',
|
|
625
|
+
code: 'relevance_reason_too_long',
|
|
626
|
+
path: `$.evidence[${index}].reason`,
|
|
627
|
+
message: `relevance reasons should be short (≤ ${MAX_REASON_LENGTH} characters); compact citations, not context dumps`,
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
let matchedTerms = [];
|
|
631
|
+
if (entry['matchedTerms'] !== undefined) {
|
|
632
|
+
if (Array.isArray(entry['matchedTerms'])) {
|
|
633
|
+
matchedTerms = entry['matchedTerms']
|
|
634
|
+
.filter((term) => isNonEmptyString(term))
|
|
635
|
+
.map((term) => term.trim());
|
|
636
|
+
if (matchedTerms.length !== entry['matchedTerms'].length) {
|
|
637
|
+
diagnostics.push({
|
|
638
|
+
severity: 'warning',
|
|
639
|
+
code: 'evidence_entry_malformed',
|
|
640
|
+
path: `$.evidence[${index}].matchedTerms`,
|
|
641
|
+
message: 'non-string or empty matchedTerms entries were dropped',
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
diagnostics.push({
|
|
647
|
+
severity: 'warning',
|
|
648
|
+
code: 'evidence_entry_malformed',
|
|
649
|
+
path: `$.evidence[${index}].matchedTerms`,
|
|
650
|
+
message: 'matchedTerms must be an array of non-empty strings when present; it was dropped',
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
// Excluded-path conflict: a manifest must not cite what it excludes.
|
|
655
|
+
const conflicting = exclusions.find((exclusion) => path === exclusion.path || path.startsWith(`${exclusion.path}/`));
|
|
656
|
+
if (conflicting !== undefined) {
|
|
657
|
+
diagnostics.push({
|
|
658
|
+
severity: 'blocked',
|
|
659
|
+
code: 'excluded_path_cited',
|
|
660
|
+
path: `$.evidence[${index}].path`,
|
|
661
|
+
message: `evidence cites '${path}', which the manifest itself excludes ('${conflicting.path}': ${conflicting.reason}); a self-contradictory manifest fails closed`,
|
|
662
|
+
});
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
// Generated/noisy citation: flagged, not silently accepted.
|
|
666
|
+
const noisy = isGeneratedOrNoisyPath(path);
|
|
667
|
+
if (noisy.noisy) {
|
|
668
|
+
diagnostics.push({
|
|
669
|
+
severity: 'warning',
|
|
670
|
+
code: 'generated_path_cited',
|
|
671
|
+
path: `$.evidence[${index}].path`,
|
|
672
|
+
message: `evidence cites generated/noisy content ('${path}' matched '${noisy.matched}'); prefer source files — generated content is weak localization evidence`,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
const lines = range;
|
|
676
|
+
if (explorer.lineWindow !== undefined && lines.end - lines.start + 1 > explorer.lineWindow) {
|
|
677
|
+
diagnostics.push({
|
|
678
|
+
severity: 'warning',
|
|
679
|
+
code: 'line_window_exceeded',
|
|
680
|
+
path: `$.evidence[${index}].lines`,
|
|
681
|
+
message: `citation spans ${lines.end - lines.start + 1} lines, exceeding the declared explorer line window of ${explorer.lineWindow}`,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
const key = `${path}:${lines.start}-${lines.end}`;
|
|
685
|
+
if (seen.has(key)) {
|
|
686
|
+
diagnostics.push({
|
|
687
|
+
severity: 'warning',
|
|
688
|
+
code: 'duplicate_evidence_entry',
|
|
689
|
+
path: `$.evidence[${index}]`,
|
|
690
|
+
message: `duplicate citation '${key}' was kept but flagged`,
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
seen.add(key);
|
|
694
|
+
entries.push({
|
|
695
|
+
path,
|
|
696
|
+
lines,
|
|
697
|
+
reason,
|
|
698
|
+
matchedTerms,
|
|
699
|
+
generatedOrNoisy: noisy.noisy,
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
if (explorer.maxFiles !== undefined) {
|
|
703
|
+
const distinctPaths = new Set(entries.map((entry) => entry.path));
|
|
704
|
+
if (distinctPaths.size > explorer.maxFiles) {
|
|
705
|
+
diagnostics.push({
|
|
706
|
+
severity: 'warning',
|
|
707
|
+
code: 'explorer_contract_invalid',
|
|
708
|
+
path: '$.evidence',
|
|
709
|
+
message: `evidence cites ${distinctPaths.size} distinct files, exceeding the declared explorer max_files bound of ${explorer.maxFiles}`,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return entries;
|
|
714
|
+
}
|
|
715
|
+
/** Returns the normalized range, or a blocking message string. */
|
|
716
|
+
function lineRangeProblem(value) {
|
|
717
|
+
if (!isPlainObject(value)) {
|
|
718
|
+
return 'lines must be an object with integer start and end';
|
|
719
|
+
}
|
|
720
|
+
const start = value['start'];
|
|
721
|
+
const end = value['end'];
|
|
722
|
+
if (typeof start !== 'number' || !Number.isInteger(start) || typeof end !== 'number' || !Number.isInteger(end)) {
|
|
723
|
+
return 'line range start/end must be integers';
|
|
724
|
+
}
|
|
725
|
+
if (start < 1 || end < 1) {
|
|
726
|
+
return 'line ranges are 1-based; zero or negative line numbers are not accepted';
|
|
727
|
+
}
|
|
728
|
+
if (end < start) {
|
|
729
|
+
return `line range is reversed (start ${start} > end ${end})`;
|
|
730
|
+
}
|
|
731
|
+
return { start, end };
|
|
732
|
+
}
|
|
733
|
+
function normalizeOpenQuestions(value, diagnostics) {
|
|
734
|
+
if (value === undefined)
|
|
735
|
+
return [];
|
|
736
|
+
if (!Array.isArray(value)) {
|
|
737
|
+
diagnostics.push({
|
|
738
|
+
severity: 'warning',
|
|
739
|
+
code: 'open_question_malformed',
|
|
740
|
+
path: '$.openQuestions',
|
|
741
|
+
message: 'openQuestions must be an array of non-empty strings when present; it was dropped',
|
|
742
|
+
});
|
|
743
|
+
return [];
|
|
744
|
+
}
|
|
745
|
+
const questions = [];
|
|
746
|
+
value.forEach((question, index) => {
|
|
747
|
+
if (isNonEmptyString(question)) {
|
|
748
|
+
questions.push(question.trim());
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
diagnostics.push({
|
|
752
|
+
severity: 'warning',
|
|
753
|
+
code: 'open_question_malformed',
|
|
754
|
+
path: `$.openQuestions[${index}]`,
|
|
755
|
+
message: 'non-string or empty open question was dropped',
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
return questions;
|
|
760
|
+
}
|
|
761
|
+
function stripGlobSuffix(path) {
|
|
762
|
+
if (path.endsWith('/**'))
|
|
763
|
+
return path.slice(0, -3);
|
|
764
|
+
if (path.endsWith('/*'))
|
|
765
|
+
return path.slice(0, -2);
|
|
766
|
+
return path;
|
|
767
|
+
}
|
|
768
|
+
function deriveManifestId(repoUrl, resolvedCommit) {
|
|
769
|
+
const cleaned = repoUrl
|
|
770
|
+
.replace(/^https:\/\//i, '')
|
|
771
|
+
.replace(/[^A-Za-z0-9._/-]+/g, '-')
|
|
772
|
+
.replace(/\/+$/, '');
|
|
773
|
+
return `${cleaned}@${resolvedCommit.slice(0, 12)}`;
|
|
774
|
+
}
|
|
775
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
776
|
+
* #509/#575 snapshot bridge — attach explorer evidence as provenance by
|
|
777
|
+
* reference (criterion 2: no full-repo ingest).
|
|
778
|
+
*
|
|
779
|
+
* `RepoExplorerSnapshotAttachment.source` is a STRUCTURAL match for the #575
|
|
780
|
+
* `OnboardingIntakeSource` shape ({ sourceUrl?, snapshotRef, checkedCommit?,
|
|
781
|
+
* crawlTimestamp }) so it can be dropped into a
|
|
782
|
+
* `sourceKind: 'static-agent-stack-snapshot'` intake descriptor unchanged —
|
|
783
|
+
* no import, per the self-contained module contract. The per-citation
|
|
784
|
+
* `evidenceRefs` satisfy the #575 `OnboardingProvenancedField` rule that
|
|
785
|
+
* `verified` provenance requires non-empty evidence refs.
|
|
786
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
787
|
+
export const REPO_EXPLORER_SNAPSHOT_REF_PREFIX = 'repo-explorer-evidence:';
|
|
788
|
+
/** Stable by-reference snapshot ref for an accepted manifest. */
|
|
789
|
+
export function repoExplorerSnapshotRef(manifest) {
|
|
790
|
+
return `${REPO_EXPLORER_SNAPSHOT_REF_PREFIX}${manifest.manifestId}`;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Per-citation evidence refs (`repo-explorer-evidence:<id>#<path>:L<start>-L<end>`),
|
|
794
|
+
* suitable as `evidenceRefs` on #575 provenanced fields.
|
|
795
|
+
*/
|
|
796
|
+
export function repoExplorerEvidenceRefs(manifest) {
|
|
797
|
+
return manifest.evidence.map((entry) => `${REPO_EXPLORER_SNAPSHOT_REF_PREFIX}${manifest.manifestId}#${entry.path}:L${entry.lines.start}-L${entry.lines.end}`);
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Bridges an accepted report onto the #509/#575 `snapshotRef` surface.
|
|
801
|
+
* Fail-closed: a blocked report (manifest null) can never become provenance.
|
|
802
|
+
*/
|
|
803
|
+
export function attachRepoExplorerEvidenceToSnapshot(report) {
|
|
804
|
+
if (report.verdict === 'blocked' || report.manifest === null) {
|
|
805
|
+
return { ok: false, reasonCode: 'manifest_blocked' };
|
|
806
|
+
}
|
|
807
|
+
const manifest = report.manifest;
|
|
808
|
+
return {
|
|
809
|
+
ok: true,
|
|
810
|
+
attachment: {
|
|
811
|
+
source: {
|
|
812
|
+
sourceUrl: manifest.source.repoUrl,
|
|
813
|
+
snapshotRef: repoExplorerSnapshotRef(manifest),
|
|
814
|
+
checkedCommit: manifest.source.resolvedCommit,
|
|
815
|
+
crawlTimestamp: manifest.generatedAt,
|
|
816
|
+
},
|
|
817
|
+
evidenceRefs: repoExplorerEvidenceRefs(manifest),
|
|
818
|
+
sourceTrust: REPO_EXPLORER_SOURCE_TRUST,
|
|
819
|
+
fullRepoIngested: false,
|
|
820
|
+
staticOnly: true,
|
|
821
|
+
},
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
export function capabilityInventoryProjection(manifest) {
|
|
825
|
+
return {
|
|
826
|
+
provenance: {
|
|
827
|
+
corpusId: manifest.manifestId,
|
|
828
|
+
sourceUrl: manifest.source.repoUrl,
|
|
829
|
+
checkedCommit: manifest.source.resolvedCommit,
|
|
830
|
+
},
|
|
831
|
+
contentTrustBoundary: 'untrusted_public_text',
|
|
832
|
+
evidenceRefs: repoExplorerEvidenceRefs(manifest),
|
|
833
|
+
localizationHints: manifest.evidence.map((entry) => ({
|
|
834
|
+
sourcePath: entry.path,
|
|
835
|
+
lines: { ...entry.lines },
|
|
836
|
+
relevance: entry.reason,
|
|
837
|
+
})),
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
export function connectorDiagnosticsProjection(report) {
|
|
841
|
+
return report.diagnostics.map((diag) => ({
|
|
842
|
+
path: diag.path,
|
|
843
|
+
diagnosticLane: 'repo_explorer_evidence',
|
|
844
|
+
severity: diag.severity,
|
|
845
|
+
warningCodes: [diag.code],
|
|
846
|
+
blocksDraftPayload: diag.severity === 'blocked',
|
|
847
|
+
operatorReviewRequired: diag.severity !== 'info',
|
|
848
|
+
message: diag.message,
|
|
849
|
+
}));
|
|
850
|
+
}
|
|
851
|
+
const EXECUTABLE_SUFFIXES = ['.sh', '.bash', '.zsh', '.ps1', '.bat', '.cmd'];
|
|
852
|
+
/** Ordered, deterministic risk classification rules — first match wins. */
|
|
853
|
+
const RISK_RULES = [
|
|
854
|
+
{
|
|
855
|
+
category: 'executable_hook',
|
|
856
|
+
code: 'explorer_cited_executable_hook',
|
|
857
|
+
matches: (path, basename) => path.startsWith('.github/workflows/') ||
|
|
858
|
+
path.split('/').slice(0, -1).some((segment) => segment.toLowerCase() === 'hooks') ||
|
|
859
|
+
(basename.startsWith('pre-') || basename.startsWith('post-')) &&
|
|
860
|
+
EXECUTABLE_SUFFIXES.some((suffix) => basename.endsWith(suffix)),
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
category: 'installer_or_update_script',
|
|
864
|
+
code: 'explorer_cited_installer_script',
|
|
865
|
+
matches: (_path, basename) => /(install|setup|update|bootstrap)/.test(basename) &&
|
|
866
|
+
EXECUTABLE_SUFFIXES.some((suffix) => basename.endsWith(suffix)),
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
category: 'deploy_capable_command',
|
|
870
|
+
code: 'explorer_cited_deploy_surface',
|
|
871
|
+
matches: (_path, basename, terms) => /deploy/.test(basename) || terms.includes('deploy'),
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
category: 'wallet_rpc_capable_metadata',
|
|
875
|
+
code: 'explorer_cited_wallet_rpc_surface',
|
|
876
|
+
matches: (path, _basename, terms) => /(wallet|keypair|private[_-]?key)/.test(path.toLowerCase()) ||
|
|
877
|
+
terms.some((term) => ['wallet', 'rpc', 'private_key', 'keypair'].includes(term)),
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
category: 'env_required_connector',
|
|
881
|
+
code: 'explorer_cited_env_requirement',
|
|
882
|
+
matches: (_path, basename, terms) => basename === '.env' || basename.startsWith('.env.') || terms.includes('env'),
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
category: 'mcp_launcher_execution',
|
|
886
|
+
code: 'explorer_cited_mcp_launcher',
|
|
887
|
+
matches: (path) => /(^|\/)\.?mcp[^/]*\.json$/i.test(path),
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
category: 'external_submodule',
|
|
891
|
+
code: 'explorer_cited_external_submodule',
|
|
892
|
+
matches: (_path, basename) => basename === '.gitmodules',
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
category: 'permission_policy',
|
|
896
|
+
code: 'explorer_cited_permission_policy',
|
|
897
|
+
matches: (_path, basename) => /(permission|policy)/.test(basename),
|
|
898
|
+
},
|
|
899
|
+
];
|
|
900
|
+
/**
|
|
901
|
+
* Deterministic risk-taxonomy projection over cited evidence paths and
|
|
902
|
+
* matched terms. Localization evidence FLAGS risk for operator review — it
|
|
903
|
+
* never auto-blocks (severity `warning`, `blocksDraftPayload: false`),
|
|
904
|
+
* because citing a risky file is observation, not adoption.
|
|
905
|
+
*/
|
|
906
|
+
export function riskTaxonomyProjection(manifest) {
|
|
907
|
+
const projections = [];
|
|
908
|
+
for (const entry of manifest.evidence) {
|
|
909
|
+
const basename = (entry.path.split('/').pop() ?? '').toLowerCase();
|
|
910
|
+
const terms = entry.matchedTerms.map((term) => term.toLowerCase());
|
|
911
|
+
const rule = RISK_RULES.find((candidate) => candidate.matches(entry.path, basename, terms));
|
|
912
|
+
if (rule === undefined)
|
|
913
|
+
continue;
|
|
914
|
+
projections.push({
|
|
915
|
+
path: entry.path,
|
|
916
|
+
diagnosticLane: 'static_fixture_risk_taxonomy',
|
|
917
|
+
category: rule.category,
|
|
918
|
+
severity: 'warning',
|
|
919
|
+
warningCodes: [rule.code],
|
|
920
|
+
blocksDraftPayload: false,
|
|
921
|
+
operatorReviewRequired: true,
|
|
922
|
+
message: `explorer evidence cites '${entry.path}' (${rule.category}); static risk review required before any adoption decision`,
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
return projections;
|
|
926
|
+
}
|
|
927
|
+
export function draftReadinessProjection(report) {
|
|
928
|
+
if (report.verdict === 'blocked' || report.manifest === null) {
|
|
929
|
+
return {
|
|
930
|
+
status: 'blocked',
|
|
931
|
+
blockers: report.diagnostics
|
|
932
|
+
.filter((diag) => diag.severity === 'blocked')
|
|
933
|
+
.map((diag) => diag.code),
|
|
934
|
+
payloadRefs: [],
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
return {
|
|
938
|
+
status: 'needs_review',
|
|
939
|
+
blockers: [],
|
|
940
|
+
payloadRefs: [repoExplorerSnapshotRef(report.manifest), ...repoExplorerEvidenceRefs(report.manifest)],
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
export function operatorReviewProjection(report) {
|
|
944
|
+
const manifest = report.manifest;
|
|
945
|
+
const status = report.verdict === 'blocked' ? 'rejected' : report.verdict === 'warning' ? 'request_changes' : 'approve_ready';
|
|
946
|
+
const reviewItems = report.diagnostics.map((diag, index) => ({
|
|
947
|
+
id: `repo-explorer-review-item-${index}`,
|
|
948
|
+
severity: diag.severity,
|
|
949
|
+
path: diag.path,
|
|
950
|
+
source: 'repo_explorer_evidence',
|
|
951
|
+
reasonCodes: [diag.code],
|
|
952
|
+
message: diag.message,
|
|
953
|
+
blocksPublication: diag.severity === 'blocked',
|
|
954
|
+
recommendedAction: diag.severity === 'blocked'
|
|
955
|
+
? 'review_unsafe_metadata'
|
|
956
|
+
: diag.severity === 'warning'
|
|
957
|
+
? 'review_static_risk'
|
|
958
|
+
: 'approve_after_readiness_gates',
|
|
959
|
+
}));
|
|
960
|
+
return {
|
|
961
|
+
reviewId: manifest === null ? 'repo-explorer-review:blocked' : `repo-explorer-review:${manifest.manifestId}`,
|
|
962
|
+
status,
|
|
963
|
+
source: {
|
|
964
|
+
sourceUrl: manifest === null ? null : manifest.source.repoUrl,
|
|
965
|
+
checkedCommit: manifest === null ? null : manifest.source.resolvedCommit,
|
|
966
|
+
sourceAuthenticity: 'source_snapshot_recorded',
|
|
967
|
+
providerTrust: 'unverified',
|
|
968
|
+
importedContentTrust: 'untrusted',
|
|
969
|
+
},
|
|
970
|
+
publication: {
|
|
971
|
+
disabled: true,
|
|
972
|
+
requiresOperatorApproval: true,
|
|
973
|
+
},
|
|
974
|
+
reviewItems,
|
|
975
|
+
rawSnapshotRefs: manifest === null ? [] : [repoExplorerSnapshotRef(manifest)],
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
export function projectRepoExplorerEvidence(report) {
|
|
979
|
+
const attachment = attachRepoExplorerEvidenceToSnapshot(report);
|
|
980
|
+
return {
|
|
981
|
+
snapshotAttachment: attachment.ok ? attachment.attachment : null,
|
|
982
|
+
capabilityInventory: report.manifest === null ? null : capabilityInventoryProjection(report.manifest),
|
|
983
|
+
connectorDiagnostics: connectorDiagnosticsProjection(report),
|
|
984
|
+
riskTaxonomy: report.manifest === null ? [] : riskTaxonomyProjection(report.manifest),
|
|
985
|
+
draftReadiness: draftReadinessProjection(report),
|
|
986
|
+
operatorReview: operatorReviewProjection(report),
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
990
|
+
* Canonical fixtures (in-memory, offline). All content is DATA and must never
|
|
991
|
+
* be treated as instructions. `example.invalid` hosts guarantee nothing here
|
|
992
|
+
* is fetchable even by mistake.
|
|
993
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
994
|
+
const FIXTURE_COMMIT = 'a3f18c9d02e14b76a3f18c9d02e14b76a3f18c9d';
|
|
995
|
+
export const repoExplorerEvidenceManifestFixtures = {
|
|
996
|
+
/** Fully accepted manifest: https source, resolved SHA, bounded read-only contract. */
|
|
997
|
+
happyPath: {
|
|
998
|
+
manifestId: 'example-agent-stack@a3f18c9d02e1',
|
|
999
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1000
|
+
source: {
|
|
1001
|
+
repoUrl: 'https://example.invalid/orgs/example/agent-stack',
|
|
1002
|
+
resolvedCommit: FIXTURE_COMMIT,
|
|
1003
|
+
defaultBranch: 'main',
|
|
1004
|
+
},
|
|
1005
|
+
sourceTrust: 'external_untrusted',
|
|
1006
|
+
explorationQuery: 'Where does this agent stack declare MCP connectors and their auth requirements?',
|
|
1007
|
+
explorer: {
|
|
1008
|
+
mode: 'read_only',
|
|
1009
|
+
maxFiles: 20,
|
|
1010
|
+
lineWindow: 120,
|
|
1011
|
+
},
|
|
1012
|
+
evidence: [
|
|
1013
|
+
{
|
|
1014
|
+
path: 'README.md',
|
|
1015
|
+
lines: { start: 1, end: 32 },
|
|
1016
|
+
reason: 'Top-level description of the agent stack and its connector list.',
|
|
1017
|
+
matchedTerms: ['mcp', 'connector'],
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
path: 'src/connectors/registry.ts',
|
|
1021
|
+
lines: { start: 44, end: 71 },
|
|
1022
|
+
reason: 'Connector registry declaring auth requirements per connector.',
|
|
1023
|
+
matchedTerms: ['auth'],
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
path: 'docs/configuration.md',
|
|
1027
|
+
lines: { start: 10, end: 25 },
|
|
1028
|
+
reason: 'Documents required environment configuration for connectors.',
|
|
1029
|
+
},
|
|
1030
|
+
],
|
|
1031
|
+
exclusions: [
|
|
1032
|
+
{ path: 'node_modules/**', reason: 'vendored dependencies', kind: 'generated' },
|
|
1033
|
+
{ path: 'dist/**', reason: 'build output', kind: 'generated' },
|
|
1034
|
+
],
|
|
1035
|
+
openQuestions: ['Which connector versions are pinned at this commit?'],
|
|
1036
|
+
},
|
|
1037
|
+
/** `..` traversal in a citation path — blocked. */
|
|
1038
|
+
pathTraversal: {
|
|
1039
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1040
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1041
|
+
explorationQuery: 'traversal fixture',
|
|
1042
|
+
evidence: [
|
|
1043
|
+
{ path: '../../etc/passwd', lines: { start: 1, end: 2 }, reason: 'traversal attempt' },
|
|
1044
|
+
],
|
|
1045
|
+
},
|
|
1046
|
+
/** Absolute citation path — blocked. */
|
|
1047
|
+
absolutePath: {
|
|
1048
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1049
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1050
|
+
explorationQuery: 'absolute path fixture',
|
|
1051
|
+
evidence: [{ path: '/etc/passwd', lines: { start: 1, end: 2 }, reason: 'absolute path attempt' }],
|
|
1052
|
+
},
|
|
1053
|
+
/** `file://` URI citation path — blocked. */
|
|
1054
|
+
fileUriPath: {
|
|
1055
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1056
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1057
|
+
explorationQuery: 'file uri fixture',
|
|
1058
|
+
evidence: [
|
|
1059
|
+
{ path: 'file:///etc/passwd', lines: { start: 1, end: 2 }, reason: 'file URI attempt' },
|
|
1060
|
+
],
|
|
1061
|
+
},
|
|
1062
|
+
/** Reversed line range — blocked. */
|
|
1063
|
+
reversedLineRange: {
|
|
1064
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1065
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1066
|
+
explorationQuery: 'reversed range fixture',
|
|
1067
|
+
evidence: [{ path: 'src/index.ts', lines: { start: 40, end: 12 }, reason: 'reversed range' }],
|
|
1068
|
+
},
|
|
1069
|
+
/** Zero/negative line numbers — blocked. */
|
|
1070
|
+
nonPositiveLineRange: {
|
|
1071
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1072
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1073
|
+
explorationQuery: 'non-positive range fixture',
|
|
1074
|
+
evidence: [
|
|
1075
|
+
{ path: 'src/index.ts', lines: { start: 0, end: 4 }, reason: 'zero start' },
|
|
1076
|
+
{ path: 'src/other.ts', lines: { start: -3, end: 4 }, reason: 'negative start' },
|
|
1077
|
+
],
|
|
1078
|
+
},
|
|
1079
|
+
/** No citations at all — blocked. */
|
|
1080
|
+
emptyEvidence: {
|
|
1081
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1082
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1083
|
+
explorationQuery: 'empty evidence fixture',
|
|
1084
|
+
evidence: [],
|
|
1085
|
+
},
|
|
1086
|
+
/** Citation into default generated/noisy content — accepted with warning. */
|
|
1087
|
+
generatedNoisyCitation: {
|
|
1088
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1089
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1090
|
+
explorationQuery: 'noisy citation fixture',
|
|
1091
|
+
evidence: [
|
|
1092
|
+
{
|
|
1093
|
+
path: 'node_modules/left-pad/index.js',
|
|
1094
|
+
lines: { start: 1, end: 5 },
|
|
1095
|
+
reason: 'vendored dependency content',
|
|
1096
|
+
},
|
|
1097
|
+
{ path: 'src/index.ts', lines: { start: 1, end: 5 }, reason: 'real source citation' },
|
|
1098
|
+
],
|
|
1099
|
+
},
|
|
1100
|
+
/** Manifest cites a path it also excludes — blocked (self-contradictory). */
|
|
1101
|
+
excludedPathCited: {
|
|
1102
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1103
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1104
|
+
explorationQuery: 'excluded citation fixture',
|
|
1105
|
+
explorer: { mode: 'read_only' },
|
|
1106
|
+
evidence: [
|
|
1107
|
+
{ path: 'generated/api-client.ts', lines: { start: 3, end: 9 }, reason: 'cites excluded content' },
|
|
1108
|
+
],
|
|
1109
|
+
exclusions: [{ path: 'generated/**', reason: 'generated API clients', kind: 'generated' }],
|
|
1110
|
+
},
|
|
1111
|
+
/** Missing relevance reason — blocked. */
|
|
1112
|
+
missingRelevanceReason: {
|
|
1113
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1114
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1115
|
+
explorationQuery: 'missing reason fixture',
|
|
1116
|
+
evidence: [{ path: 'src/index.ts', lines: { start: 1, end: 4 }, reason: ' ' }],
|
|
1117
|
+
},
|
|
1118
|
+
/** Self-asserted higher trust level — blocked. */
|
|
1119
|
+
trustBoundaryViolation: {
|
|
1120
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1121
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1122
|
+
sourceTrust: 'trusted_internal',
|
|
1123
|
+
explorationQuery: 'trust violation fixture',
|
|
1124
|
+
evidence: [{ path: 'src/index.ts', lines: { start: 1, end: 4 }, reason: 'citation' }],
|
|
1125
|
+
},
|
|
1126
|
+
/** Non-read-only explorer mode — blocked. */
|
|
1127
|
+
nonReadOnlyExplorer: {
|
|
1128
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1129
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1130
|
+
explorationQuery: 'mode violation fixture',
|
|
1131
|
+
explorer: { mode: 'read_write' },
|
|
1132
|
+
evidence: [{ path: 'src/index.ts', lines: { start: 1, end: 4 }, reason: 'citation' }],
|
|
1133
|
+
},
|
|
1134
|
+
/** Branch name instead of a resolved commit SHA — blocked. */
|
|
1135
|
+
unresolvedCommit: {
|
|
1136
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1137
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: 'main' },
|
|
1138
|
+
explorationQuery: 'unresolved commit fixture',
|
|
1139
|
+
evidence: [{ path: 'src/index.ts', lines: { start: 1, end: 4 }, reason: 'citation' }],
|
|
1140
|
+
},
|
|
1141
|
+
/** Non-https source URL — blocked. */
|
|
1142
|
+
unsafeSourceUrl: {
|
|
1143
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1144
|
+
source: { repoUrl: 'file:///Users/someone/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1145
|
+
explorationQuery: 'unsafe source url fixture',
|
|
1146
|
+
evidence: [{ path: 'src/index.ts', lines: { start: 1, end: 4 }, reason: 'citation' }],
|
|
1147
|
+
},
|
|
1148
|
+
/** Risky cited surfaces for the #421 risk-taxonomy projection. */
|
|
1149
|
+
riskyEvidence: {
|
|
1150
|
+
generatedAt: '2026-07-06T00:00:00Z',
|
|
1151
|
+
source: { repoUrl: 'https://example.invalid/orgs/example/agent-stack', resolvedCommit: FIXTURE_COMMIT },
|
|
1152
|
+
explorationQuery: 'risk surface fixture',
|
|
1153
|
+
evidence: [
|
|
1154
|
+
{
|
|
1155
|
+
path: '.github/workflows/deploy.yml',
|
|
1156
|
+
lines: { start: 1, end: 18 },
|
|
1157
|
+
reason: 'CI workflow with deploy step',
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
path: 'scripts/install.sh',
|
|
1161
|
+
lines: { start: 1, end: 12 },
|
|
1162
|
+
reason: 'installer script cited for review',
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
path: 'src/payments/signer.ts',
|
|
1166
|
+
lines: { start: 5, end: 20 },
|
|
1167
|
+
reason: 'wallet signing surface',
|
|
1168
|
+
matchedTerms: ['wallet', 'rpc'],
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
path: 'connectors/mcp.config.json',
|
|
1172
|
+
lines: { start: 1, end: 9 },
|
|
1173
|
+
reason: 'MCP launcher configuration',
|
|
1174
|
+
matchedTerms: ['mcp'],
|
|
1175
|
+
},
|
|
1176
|
+
],
|
|
1177
|
+
},
|
|
1178
|
+
};
|
|
1179
|
+
/* ────────────────────────────────────────────────────────────────────────────
|
|
1180
|
+
* Shared helpers
|
|
1181
|
+
* ──────────────────────────────────────────────────────────────────────────── */
|
|
1182
|
+
function isPlainObject(value) {
|
|
1183
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1184
|
+
}
|
|
1185
|
+
function isNonEmptyString(value) {
|
|
1186
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
1187
|
+
}
|