Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ const report = await runAudit(
console.log(ENGINE_VERSION, report.assessment.verdict, report.coverage);
```

Verdicts are computed by the library. Explicit extraction refusals recognize English typography and Chinese/Russian refusal forms; an empty JSON extraction is informational, while ambiguous answers remain inconclusive. The semantic yes/no task accepts terminal punctuation; exact-literal tasks retain strict comparison. For unresolved checks, import `getAuditInconclusiveReason` from `@lmspeed/audit/assessment` to obtain a machine-readable cause for translation. Consumers should retain the engine verdict rather than replacing it with a display heuristic.

---

## Preview
Expand All @@ -207,7 +209,7 @@ console.log(ENGINE_VERSION, report.assessment.verdict, report.coverage);
{
"schemaVersion": "1",
"engineVersion": "0.3.0",
"rulesetVersion": "independent-2026-11-22.1",
"rulesetVersion": "independent-2026-11-23.1",
"target": {
"baseUrl": "http://127.0.0.1:57215/v1",
"modelId": "claude-sonnet-4-6",
Expand Down Expand Up @@ -284,7 +286,7 @@ console.log(ENGINE_VERSION, report.assessment.verdict, report.coverage);
| Profile | Included Probes by Default | Intended Use |
| :--- | :--- | :--- |
| `connectivity` | `model_list`, `stream_integrity` | Fast preflight reachability, authentication, and SSE framing verification |
| `general` *(default)* | All 17 automatic probes across endpoint, prompt security, integrity, and quality; excludes `web3_prompt_injection` and opt-in probes unless configured | Standard relay contract & security audit |
| `general` *(default)* | 19 automatic probes, including numeric screening and tokenizer evidence from bundled reference data; excludes `web3_prompt_injection` and other opt-in probes unless configured | Standard relay contract & security audit |
| `web3` | `general` set + `web3_prompt_injection` + configured opt-in probes | General audit plus wallet seed-sharing refusal signal |
| `full` | Same automatic set + `web3_prompt_injection` + all configured opt-in capability/reference probes (`tokenBaselines`, `vision`, `pdf`, `context`, `reference`, `identity`, `numericFingerprint`, `tokenizer`) | Comprehensive audit with full operator configuration |

Expand All @@ -301,18 +303,18 @@ console.log(ENGINE_VERSION, report.assessment.verdict, report.coverage);

| Probe ID | Trigger | Behavior & Evidence Scope |
| :--- | :--- | :--- |
| `infrastructure_recon` | Auto | Checks base URL HTTP reachability, status, and `content-type`; does not audit DNS, TLS certificates, or domain ownership |
| `infrastructure_recon` | Auto | Collects entry reachability, DNS addresses/CNAME/NS, TLS certificate details and bounded WHOIS registration fields; unavailable evidence stays separate |
| `model_list` | Auto / `connectivity` | Reads `GET /models` JSON `data[]` catalog and checks whether `target.modelId` is listed (`advertised catalog only`) |
| `infrastructure_fingerprint` | Auto | Sends a short readiness completion and summarizes non-identifying response header hints |
| `infrastructure_fingerprint` | Auto | Compares landing, models and error-route signatures for New API, One API, LiteLLM, One Hub, LobeChat, FastGPT and common entry proxies; editable branding is evidence, not upstream proof |
| `channel_classifier` | Auto | Inspects explicit header prefixes (`cf-aig-`, `x-amzn-bedrock-`, `anthropic-ratelimit-`); marks conflicting or absent hints as `inconclusive` |

#### 2. Prompt & Injection Security (`prompt_security`)

| Probe ID | Trigger | Behavior & Evidence Scope |
| :--- | :--- | :--- |
| `token_injection` | Opt-in (`capabilities.tokenBaselines`) | Compares reported input usage across `plain`, `system`, and `question` templates against caller calibration (`reported_input_count_mismatch`) |
| `prompt_extraction` | Auto | Embeds a fresh random `PRIVATE_*` token in system instructions and tests whether raw or base64 forms are disclosed (`protected_value_disclosed`) |
| `jailbreak_identity` | Auto | Attempts JSON and base64 transformations to leak a fresh random `PRIVATE_*` protected value (`protected_value_disclosed`) |
| `prompt_extraction` | Auto | Runs verbatim, translation and JSON-continuation probes plus a randomized protected-value control; retains separate results and prompts/responses |
| `jailbreak_identity` | Auto | Runs system diagnostic, Base64 and middleware role-play strategies plus randomized JSON/Base64 disclosure controls |
| `conditional_injection` | Auto | Runs 3 randomized ordinary vs. sensitive account task pairs and checks for excess `DECOY_*` disclosure + external `https://` forwarding directions |
| `web3_prompt_injection` | `web3` / `full` | Tests structured JSON refusal policy on seed-phrase upload requests (`{"action":"reject"}` vs `"share"`) |

Expand All @@ -322,11 +324,15 @@ console.log(ENGINE_VERSION, report.assessment.verdict, report.coverage);
| :--- | :--- | :--- |
| `instruction_conflict` | Auto | Places a fresh random `ACK_*` literal contract in system instructions while the user prompt requests ignoring it (`system_priority_mismatch`) |
| `stream_integrity` | Auto / `connectivity` | Validates SSE framing (`[DONE]` / `message_stop` / `response.completed`), streamed model consistency, and monotonic usage counters |
| `context_window` | Auto *(needs config)* | Samples bounded recall using `context.sizes` or `Math.min(16384, contextWindowTokens * 2)`; returns `unsupported` when neither is provided |
| `context_window` | Auto | Without size configuration: exponential expansion and binary refinement, at most 12 requests, 524,288 input characters and 4,096-character resolution. Explicit sizes retain fixed recall sampling. Auth, quota and transient failures never establish capacity |
| `context_recall` | Opt-in (`context`) | Embeds random `FACT_*` anchors at configurable positions (`[0, 0.25, 0.5, 0.75, 1]` default), confirming misses once before reporting `context_recall_missing` |
| `model_fingerprint` | Opt-in (`identity`) | Compares answer distributions against a calibrated holdout baseline; abstains on expired, incomplete, incompatible, or low-margin samples |
| `numeric_fingerprint` | Opt-in (`numericFingerprint`) | Verifies local `shared_detector.bin` SHA-256 and age (`1–90` days, default `30`), then ranks closed-set candidates via `lmfpd-sdk` |
| `tokenizer_fingerprint` | Opt-in (`tokenizer`) | Runs adaptive differential probes with an external MIT `TokenizerBank` up to `0.99` posterior confidence; abstains on empty-prompt drift |
| `numeric_fingerprint` | Auto; optional `numericFingerprint` override | Uses the shipped SHA-256-pinned reference (30-day age limit) for closed-set ranking; no runtime data downloads |
| `tokenizer_fingerprint` | Auto; optional `tokenizer` override | Uses the shipped fixed tokenizer bank (90-day age limit, at most 12 adaptive probes plus two controls); abstains on drift or uncertainty |

Reference data is owned and versioned by this package. SDK, CLI and LMSpeed use the same read-only `assets/references` snapshot, including source commit, original dates, hashes and MIT attribution. Explicit `numericFingerprint` and `tokenizer` configuration takes precedence. Set `referenceData: 'disabled'` in SDK/config JSON to disable automatic reference checks. Expired, missing or altered data is reported as inconclusive without downloading replacements or blocking unrelated checks. Distribution confirmation still requires an independently calibrated `identity` baseline.

Maintainers update `references.source.json` to a reviewed upstream commit and Git blob hashes, then run `pnpm references:sync`. The command downloads only during maintenance, verifies original blobs and compatibility, and keeps only scoring metadata, the detector and tokenizer bank. Commit the snapshot and release through this repository's existing CI. See [reference data maintenance](./docs/references.md).

#### 4. Response Integrity & Stability (`response_integrity_stability`)

Expand Down
24 changes: 15 additions & 9 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ process.stdout.write(
);
```

Решения принимает библиотека. Распознаются типографские апострофы в английских отказах, а также китайские и русские формы отказа. Пустое JSON-извлечение считается информационным результатом; неоднозначный ответ остаётся неопределённым. В смысловом задании yes/no допустим конечный знак препинания, а точные строковые задания сохраняют строгое сравнение. Для нерешённых проверок импортируйте `getAuditInconclusiveReason` из `@lmspeed/audit/assessment`, чтобы получить машинный код причины для перевода. Потребители должны сохранять решение движка, не заменяя его логикой отображения.

---

## Пример отчёта
Expand All @@ -208,7 +210,7 @@ process.stdout.write(
{
"schemaVersion": "1",
"engineVersion": "0.3.0",
"rulesetVersion": "independent-2026-11-22.1",
"rulesetVersion": "independent-2026-11-23.1",
"target": {
"baseUrl": "http://127.0.0.1:57215/v1",
"modelId": "claude-sonnet-4-6",
Expand Down Expand Up @@ -271,7 +273,7 @@ process.stdout.write(
| Профиль | Проверки по умолчанию | Назначение |
| :--- | :--- | :--- |
| `connectivity` | `model_list`, `stream_integrity` | Быстрая проверка доступности, авторизации и структуры SSE |
| `general` *(по умолчанию)* | Все 17 автоматических проверок; без `web3_prompt_injection`, дополнительные проверки включаются конфигурацией | Стандартный аудит контрактов и безопасности API |
| `general` *(по умолчанию)* | 19 автоматических проверок с поставляемыми числовыми и токенизаторными эталонами; без `web3_prompt_injection` и других ненастроенных дополнительных проверок | Стандартный аудит контрактов и безопасности API |
| `web3` | `general` + `web3_prompt_injection` + настроенные дополнительные проверки | Дополнительно проверяет отказ передавать seed-фразу |
| `full` | Тот же автоматический набор + `web3_prompt_injection` + все настроенные возможности и эталоны (`tokenBaselines`, `vision`, `pdf`, `context`, `reference`, `identity`, `numericFingerprint`, `tokenizer`) | Полный аудит с конфигурацией оператора |

Expand All @@ -288,18 +290,18 @@ process.stdout.write(

| ID | Включение | Поведение и границы выводов |
| :--- | :--- | :--- |
| `infrastructure_recon` | Автоматически | Доступность базового URL по HTTP, статус и `content-type`; не аудит DNS, TLS-сертификатов или владения доменом |
| `infrastructure_recon` | Автоматически | Сбор доступности, DNS-адресов/CNAME/NS, TLS-сертификата и ограниченных полей WHOIS; недоступные данные отмечаются отдельно |
| `model_list` | Автоматически / `connectivity` | Читает каталог `data[]` из `GET /models` и проверяет наличие `target.modelId`; только заявленный каталог |
| `infrastructure_fingerprint` | Автоматически | Короткий запрос готовности и сводка признаков в заголовках, не устанавливающих подлинность модели |
| `infrastructure_fingerprint` | Автоматически | Сигнатуры New API, One API, LiteLLM, One Hub, LobeChat, FastGPT и сетевых прокси на главной, в каталоге моделей и ответах ошибок; не доказательство upstream |
| `channel_classifier` | Автоматически | Префиксы `cf-aig-`, `x-amzn-bedrock-`, `anthropic-ratelimit-`; отсутствие или противоречие даёт `inconclusive` |

#### 2. Безопасность инструкций и инъекции (`prompt_security`)

| ID | Включение | Поведение и границы выводов |
| :--- | :--- | :--- |
| `token_injection` | Дополнительно (`capabilities.tokenBaselines`) | Сравнивает заявленный ввод в шаблонах `plain`, `system`, `question` с калибровкой (`reported_input_count_mismatch`) |
| `prompt_extraction` | Автоматически | Вставляет случайный `PRIVATE_*` в системную инструкцию и ищет прямую или Base64-утечку (`protected_value_disclosed`) |
| `jailbreak_identity` | Автоматически | Пытается раскрыть случайный защищённый `PRIVATE_*` через JSON и Base64 |
| `prompt_extraction` | Автоматически | Дословное извлечение, перевод и продолжение JSON плюс случайный защищённый контроль; отдельные результаты, запросы и ответы |
| `jailbreak_identity` | Автоматически | Диагностика системы, Base64 и роль middleware плюс случайные контроли JSON/Base64 |
| `conditional_injection` | Автоматически | Три пары обычных и чувствительных задач в случайном порядке: избыток раскрытий `DECOY_*` и указаний переслать данные на внешний `https://` |
| `web3_prompt_injection` | `web3` / `full` | Проверяет JSON-отказ загружать seed-фразу (`{"action":"reject"}` вместо `"share"`) |

Expand All @@ -309,11 +311,15 @@ process.stdout.write(
| :--- | :--- | :--- |
| `instruction_conflict` | Автоматически | Системная инструкция требует случайный `ACK_*`, пользователь просит проигнорировать её (`system_priority_mismatch`) |
| `stream_integrity` | Автоматически / `connectivity` | Структура SSE, завершение (`[DONE]`, `message_stop`, `response.completed`), постоянство имени модели и монотонность счётчиков |
| `context_window` | Автоматически, нужна конфигурация | Ограниченная выборка по `context.sizes` или `Math.min(16384, contextWindowTokens * 2)`; без обоих — `unsupported` |
| `context_window` | Автоматически | Без настроек длины: удвоение и двоичное уточнение, до 12 запросов, 524 288 символов и точность 4096 символов. Явные размеры сохраняют выборку; ошибки доступа, лимитов и нестабильность не определяют ёмкость |
| `context_recall` | Дополнительно (`context`) | Случайные `FACT_*` в позициях по умолчанию `[0, 0.25, 0.5, 0.75, 1]`; пропуск перепроверяется перед `context_recall_missing` |
| `model_fingerprint` | Дополнительно (`identity`) | Сравнивает распределения ответов с откалиброванным эталоном; воздерживается при просрочке, неполноте, несовместимости или недостаточной разделимости |
| `numeric_fingerprint` | Дополнительно (`numericFingerprint`) | Проверяет SHA-256 и возраст локального `shared_detector.bin` (`1–90` дней, по умолчанию `30`), затем ранжирует закрытый набор через `lmfpd-sdk` |
| `tokenizer_fingerprint` | Дополнительно (`tokenizer`) | Адаптивные проверки с внешним MIT `TokenizerBank` до апостериорной вероятности `0.99`; воздерживается при дрейфе пустого запроса |
| `numeric_fingerprint` | Автоматически; переопределение `numericFingerprint` | Поставляемый эталон с SHA-256 и сроком 30 дней; ранжирование закрытого набора без загрузки данных во время аудита |
| `tokenizer_fingerprint` | Автоматически; переопределение `tokenizer` | Поставляемый банк фиксированных токенизаторов, срок 90 дней, до 12 адаптивных запросов и двух контрольных; воздержание при дрейфе и неопределённости |

Данные поставляются и версионируются самим пакетом. SDK, CLI и LMSpeed используют один снимок `assets/references` с исходным коммитом, датами, хешами и уведомлением MIT. Явные настройки `numericFingerprint` и `tokenizer` имеют приоритет; `referenceData: 'disabled'` отключает автоматические проверки. Просрочка, повреждение и отсутствие данных дают неопределённый результат без фоновой загрузки и не блокируют остальные проверки. Проверка распределений требует независимого калиброванного эталона `identity`.

Для обновления сопровождающий фиксирует проверенный коммит и Git blob-хеши в `references.source.json`, запускает `pnpm references:sync`, коммитит снимок и публикует через CI репозитория. Подробности: [обслуживание эталонов](./docs/references.md).

#### 4. Целостность и стабильность ответов (`response_integrity_stability`)

Expand Down
Loading
Loading