Skip to content

feat(dpr): provider-only policy target — strict single-subscription routing (#351) - #352

Merged
saymer-alt merged 8 commits into
mainfrom
feat/dpr-provider-target-351
Nov 9, 2026
Merged

saymer-alt merged 8 commits into
mainfrom
feat/dpr-provider-target-351

Conversation

@saymer-alt

@saymer-alt saymer-alt commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Актуальный integration/evidence snapshot — 09.11.2026


Что реализовано

Opt-in цель DPR-карточки «🛰 Только <provider> (строго одна подписка)» (#351): домены выбранной политики направляются строго через один указанный HTTP provider — правило RULE-SET ведёт в provider-only url-test-группу NAME-AUTO с use: [<выбранный provider>]. Другие подписки в маршруте политики не участвуют вовсе; MATCH,GLOBAL, GLOBAL-группа, SELECT/GLOBAL/REJECT-семантика и no-DIRECT-контракт #284 не изменены.

Closes требования issue #351 в объёме P1-slice (не претендует на полную VPS V3 parity из #278).

SOURCE-GROUNDED GAP (воспроизведён синтетически)

Базовое состояние (test 1 tests/dpr-provider-target.cjs): в Sub Mode ON NAME-AUTO пулит все proxy-providers подписок:

providers: [ subs-a.example.invalid, subs-b.example.invalid ]
GEMINI-AUTO use: ["subs-a.example.invalid","subs-b.example.invalid"]   ← нельзя выбрать один

Это документированная SELECT-семантика, не дефект; #351 добавляет строгую альтернативу, не меняя дефолт.

Дизайн (минимальный, в существующей архитектуре)

  • Модель карточки/проекта: target-строка PROVIDER:<имя подписки> — схема проекта ({name, domains, target} strings) не менялась; старые проекты совместимы.
  • UI: опции «🛰 Только …» появляются из реестра целей dialerTargetsCache (точные имена движка, включая суффиксы дедупликации) только при Sub Mode ON; обновляются живо (input/change-диспетчер); исчезнувшая подписка отображается честно («подписка отсутствует — Build будет отклонён»), выбор не сбрасывается молча.
  • Слои: в движок карта уходит как SELECT-плейсхолдер (движок строит NAME-AUTO+NAME+правило на NAME); пост-патч applyDprProviderTargets(yaml, wanted) (маркеры DPT-START/END в index.html, тот же код в браузере и node-тестах) переписывает правило на NAME-AUTO, ставит use:[provider] и empty-fallback: REJECT.
  • Fail-closed (явные ошибки Build, никакой тихой деградации):
    • выбранная подписка отсутствует в proxy-providers;
    • NAME-AUTO или RULE-SET-правило не найдено (контракт движка изменился);
    • Sub Mode OFF — «provider-цель существует только у подписок»;
    • AWL ON — «в AWL у категорий нет AUTO-групп»;
    • если группа действительно пуста → empty-fallback: REJECT; если узлы A существуют, но все unhealthy → в синтетической netns-лаборатории наблюдалась dial-ошибка/502 без egress через B/DIRECT (Mihomo 1.19.31/1.19.33, PR test(dpr): netns runtime-proof — provider-only DPR при all-unhealthy A и живом B (#355) #360), а не срабатывание empty-fallback.
  • Чистота вывода: недостижимая NAME select-группа удаляется только при нулевых оставшихся ссылках (правила/члены групп/dialer-proxy); при наличии ссылок честно остаётся. Патч выполняется до Tiered/профиль-патчей; без PROVIDER-карт — байт-в-байт (OFF parity проверена).
  • web4core.runtime.js не тронут (generated artifact); изменения — index.html (UI/патч) + CI + docs.

Тесты

  • tests/dpr-provider-target.cjs (node, 12 проверок): baseline-gap репродукция; строго use:[A], B отсутствует; mixed SELECT+PROVIDER; OFF byte-parity; 4 fail-closed; честное сохранение referenced select; слой-контракт (движок отвергает PROVIDER напрямую); GLOBAL untouched; отсутствие новых URL/токенов; hardening. Локально 12/12.
  • tests/dpr-provider-target-browser.cjs (Playwright): UI-путь (опции реестра, выбор, Build VALID), проектный roundtrip PROVIDER:<имя>, Sub Mode OFF (честное отображение + fail-closed), AWL fail-closed, живое обновление реестра; мониторинг pageerror + отсутствие не-CDN запросов.
  • tests/dpr-provider-target-mihomo-compat.cjs (parse-only mihomo -t, обе пиновые версии): baseline, provider-target, mixed PASS; negative integrity proof — dangling RULE-SET отвергается бинарём.
  • Регрессии локально: policy-routing 33, no-direct-egress 18, routing-inspector 59, config-import 11, config-roundtrip 10, dependency-graph 16, rule-provider-explorer 25, per-node-generation 18, security-stress 49, physical-topology 22, runtime 65 — PASS.

CI

Обязательный прогон на pinned 1.19.31 и 1.19.33 — mihomo-compat job, оба PASS.

Per-check evidence на head e7b63c5ea7fc66fe9e9b006534b030b419a3795f:

  • tests/dpr-provider-target.cjs — 12 passed, 0 failed (deterministic/static+node);
  • tests/dpr-provider-target-browser.cjs — 7 passed, 0 failed (deterministic/browser);
  • tests/dpr-provider-target-mihomo-compat.cjs — 5 parse-only cases PASS на обеих пиновых версиях.

История прогонов (честно): первый run 42482521853 на 3a5ff6a — deterministic/browser FAIL: 2 дефекта самой реализации (provider-опции карточек создавались без маркера data-dpr-provider — refresh оставлял дубли/устаревшие опции; неверный тест-предикат). Исправлено в e7b63c5 («fix(dpr): mark all provider options with data-dpr-provider — refresh owns rebuild»); продуктовые job'ы (compat 1.19.31/1.19.33, static+node, owner UX) были зелёные уже на 3a5ff6a. Итоговый PASS — на e7b63c5.

Workflow Run Результат
Generator CI 42483142372 success 6/6 (static+node, browser, owner-UX firefox, owner-UX webkit, compat 1.19.31, compat 1.19.33)
Update web4core runtime 42483142381 success

Field / NOT TESTED (честные границы)

Merge только после отдельного owner GO.

…outing (#351)

Opt-in DPR card target '🛰 Только <provider>' (PROVIDER:<name>): RULE-SET
goes strictly to a provider-only url-test group (use: [chosen provider]);
other subscriptions never enter the policy route. Engine receives a SELECT
placeholder; applyDprProviderTargets post-patch rewrites the rule, sets
empty-fallback REJECT (no-DIRECT #284), removes the unreachable NAME select
only when unreferenced. Fail-closed: missing provider/group/rule, Sub Mode
OFF, AWL — explicit build errors, no silent fallback. Provider options live
in the dialer target registry; project persists PROVIDER:<name>.

Tests: tests/dpr-provider-target.cjs (12 node), browser UI regression,
mihomo -t parse-only contracts on pinned 1.19.31/1.19.33. SELECT semantics,
GLOBAL, MATCH,GLOBAL and no-DIRECT contracts unchanged.
…owns rebuild (#351)

CI run 42482521853 deterministic/browser: policyCardDom emitted provider
options without the refresh marker, so registry updates left duplicate/
stale unmanaged options. All provider options now carry data-dpr-provider;
refreshPolicyProviderOptions rebuilds them consistently. Test predicate for
Sub Mode OFF corrected (expects exactly one honest missing-subscription slot).
Combine provider-only routing with provider name sync and RU/EN foundation; do not change project semantics or runtime generated artifacts.
…icies (#351)

Mutate the current proxy-groups array in place; add regression proving both policies keep independent providers and remove both unreferenced SELECT groups.

Copy link
Copy Markdown
Owner Author

Independent review + sync checkpoint — 08.11.2026

Merge: requires separate owner GO; keep Draft. Related #351 and VPS umbrella #278.

…llback (#351)

Block bare/whitespace-only PROVIDER: targets before they can be normalized into pooled SELECT. Add Node and browser regressions, and clarify that Mihomo empty-fallback covers empty groups, not proven all-unhealthy no-leak behavior.
…#351)

Fail-closed malformed provider targets must reset the previous YAML validation result; UI and copy controls must show the failed build. Add browser regression for ERROR and disabled copy.

Copy link
Copy Markdown
Owner Author

Independent safety review #351/#352 — bounded follow-up (08.11.2026)

Current PR HEAD: 243f171b3f28765aeebc55c6d669be50ec6e0456; current main: e365f96b86e63f6e19e1713948014574f31c8fb3. Draft, NO MERGE without owner GO. Relative diff remains six intended files (no stable, Pages, releases, VPS/routers or web4core.runtime.js edits). The agent's original CI SUCCESS at e7b63c5 cannot be substituted for a new SHA.

Review findings/fixes after sync:

  1. 23592970: processing two provider-only cards could resurrect the orphan SELECT group from the first card due to filtering a stale groups array. Fixed in-place and added a two-policy node regression.
  2. e148173: a malformed saved PROVIDER: (empty/whitespace-only name) could be silently normalized to SELECT and widen the route to all subscription providers. Guarded at both UI collection and applyDprProviderTargets; added Node and browser negative regression.
  3. Upstream docs specify empty-fallback for an empty group, not a guaranteed REJECT for a nonempty all-unhealthy group. Corrected the misleading product-help/doc statement. Official documentation: https://wiki.metacubex.one/ru/config/proxy-groups/ .
  4. First new browser regression found a real second-order UI defect: Build failure left stale MIHOMO_VALIDATION_STATE=VALID visible from previous successful generation (copy was gated separately by builderBuildError). 243f171 resets validation to NOT_BUILT in policy-collection catch; browser test now checks state, action ERROR, copy disabled, and exact malformed target retained.

Evidence: On latest SHA 243f171, runtime provenance #42487299614 SUCCESS. Generator CI #42487299625 is RUNNING at this checkpoint; static + node, both Mihomo compat (1.19.31/1.19.33), Firefox already SUCCESS; Chromium and WebKit not yet final. Do not mark READY until all are complete SUCCESS.

Independent runtime/egress STOP scope: mihomo -t is syntax/structure evidence, NOT a live all-unhealthy/no-VPS-direct guarantee. Recorded a concrete positive/negative isolated netns acceptance proposal in #284 comment, potentially reusing test-only Draft #338. No live owner config was touched.

Next owner decision only after final exact-SHA CI and independent risk review.

Copy link
Copy Markdown
Owner Author

Final independent-review handoff — 08.11.2026 — exact SHA VERIFIED

PR #352 HEAD 243f171b3f28765aeebc55c6d669be50ec6e0456 (base main=e365f96b86e63f6e19e1713948014574f31c8fb3) — Draft / OPEN / mergeable CLEAN, six expected files only; no production/runtime generated artifact, stable, Pages, release or live VPS changes.

Latest full mandatory CI is GREEN on exactly this head:

  • Generator CI run #42487299625: 6/6 SUCCESS (static+node, Chromium browser, Firefox UX, WebKit UX, Mihomo compat 1.19.31 and 1.19.33).
  • Runtime provenance #42487299614: SUCCESS.
  • Earlier run #42486851619 browser FAIL on the newly added malformed-target regression revealed the old VALID state remained visible after a Build rejection, despite copy already being gated off. This was fixed in product in commit 243f171 by resetting the previous validation state; the browser test now checks NOT_BUILT / ERROR / copy-disabled.

Review fixes: (1) multiple provider-only policies no longer resurrect obsolete SELECT groups (23592970); (2) malformed PROVIDER: with no provider name blocks Build instead of silently degrading to pooled SELECT (e148173); (3) product help/docs now accurately distinguish group empty-fallback from an all-unhealthy provider; (4) stale validation status no longer looks successful after rejected policy Build (243f171). Original #351 functionality and #346/#350 integrations retained.

Outstanding runtime proof — explicitly NOT TESTED: provider A has nodes but all are unhealthy while provider B is healthy: prove no user-plane fallback to B or host DIRECT, including IPv4/IPv6 and cold-start. See #284 scoped netns follow-up and existing Draft #338 test lab; no real VPS tests. Upstream empty-fallback is for empty groups, not a substitute for this runtime test.

Verdict: Code/CI READY FOR OWNER REVIEW; NO live no-leak E2E verdict, NO release/deploy GO. Merge requires a separate explicit owner GO; PR remains Draft.

Preserve strict provider routing and current RU/EN Builder; integrate both UI and CI test suites without changing generated runtime.

Copy link
Copy Markdown
Owner Author

Integration after merge #354 (08.11.2026)

Boundary: subsequent edits to main or this PR HEAD require a fresh cross-check + exact-SHA CI.

…338

Preserve provider-only DPR implementation, i18n UI and rootless lab guard CI. Review and retest at resulting exact SHA before any merge.

Copy link
Copy Markdown
Owner Author

Integration checkpoint after merged #338 — 2026-11-09

PR #352 remains OPEN DRAFT; new HEAD 3da32d06fee5d570fba27dd133a5d122d588700b, synced to main=cf44e5318f01def5469cccc330240f715213d837 (which includes merged netns lab #338).

A clean exact-diff transplant preserved six DPR files only: .github/workflows/generator-ci.yml, docs/POLICY-ROUTING.md, index.html, and three DPR-specific tests. Combined CI workflow retains both the rootless netns-lab guard from #338 and the DPR Node/browser/compat test steps. Neither web4core.runtime.js nor stable/Pages/release/live servers touched.

Next: await exact-head CI; decide separately whether to merge #352. On merge, reconstruct #360 to contain only its own DPR scenario files and rerun exact-SHA CI.

saymer-alt added a commit that referenced this pull request Nov 9, 2026
…352 (#355)

Keep only four DPR-specific lab files on top of current #352 tree. Use merged hardened isolation gate and rootless CI checks from main. Preserve historical runtime evidence SHAs; new CI covers this combined head.

Copy link
Copy Markdown
Owner Author

Independent exact-SHA CI completion checkpoint — 2026-11-09

Read-only recheck of current Draft PR #352 (no new commit, no merge):

@saymer-alt
saymer-alt marked this pull request as ready for review November 9, 2026 17:58
@saymer-alt
saymer-alt merged commit 7e2e6fa into main Nov 9, 2026
10 checks passed
@saymer-alt
saymer-alt deleted the feat/dpr-provider-target-351 branch November 9, 2026 17:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T18:00:52.013345Z 3da32d0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

saymer-alt added a commit that referenced this pull request Nov 9, 2026
…ct tree)

Merge parents: existing #360 HEAD and squash merge of #352 into main.
Keep five test-only lab files and preserve all main product blobs unchanged.
No production changes or field claim.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3da32d06fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread index.html
Comment on lines +1966 to +1967
if (!Object.prototype.hasOwnProperty.call(providers, provider)) {
throw new Error('Provider-цель политики «' + name + '»: подписка «' + provider + '» отсутствует в proxy-providers — измените выбор цели или пересоберите с актуальными подписками');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bind strict policy targets to stable subscription identities

When two subscriptions share a hostname, the stored provider name does not reliably identify the selected subscription. The runtime's computeProviderName() assigns hostname-based names and positional deduplication suffixes, so selecting PROVIDER:subs.example.invalid for /account-a and then removing that URL or moving /account-b before it silently retargets the policy to /account-b. I reproduced both cases against this commit: the existence check passes and the patched group uses the other subscription instead of rejecting the missing selection. Preserve a stable source-to-target binding across registry refreshes and project roundtrips, or require explicit reselection when the source behind a provider name changes.

Useful? React with 👍 / 👎.

saymer-alt added a commit that referenced this pull request Nov 9, 2026
Preserve existing 5 lab-only changes and merged #352; integrate main's CONTRIBUTING.md unchanged. No runtime or production change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant